Skip to content

Commit

Permalink
Flow specs on all frameworks.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfitzgibbons committed Jan 24, 2012
1 parent b8093ac commit 3d6d098
Show file tree
Hide file tree
Showing 104 changed files with 913 additions and 144 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ deps
dist
pkg
*.app
docs-*
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ gem 'swt'

group :development do
gem "ruby-debug"
#gem "guard"
gem "guard"
gem "guard-rspec"
#gem "spork"

#gem 'yard'
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ GEM
term-ansicolor (>= 1.0.6)
diff-lcs (1.1.3)
facets (2.9.2)
ffi (1.0.11-java)
gherkin (2.5.1)
json (>= 1.4.6)
gherkin (2.5.1-java)
json (>= 1.4.6)
guard (1.0.0)
ffi (>= 0.5.0)
thor (~> 0.14.6)
guard-rspec (0.6.0)
guard (>= 0.10.0)
json (1.6.1)
json (1.6.1-java)
linecache (0.46)
Expand All @@ -38,6 +44,7 @@ GEM
ruby-debug-base (0.10.4-java)
swt (0.12)
term-ansicolor (1.0.6)
thor (0.14.6)

PLATFORMS
java
Expand All @@ -47,6 +54,8 @@ DEPENDENCIES
cucumber
facets
gherkin
guard
guard-rspec
log4jruby
rake
rspec
Expand Down
106 changes: 106 additions & 0 deletions archive/base_framework_adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
module BaseFrameworkAdapter
module Shoes
class Base
attr_accessor :adapted_object

def initialize(adapted_object)
self.adapted_object = adapted_object
end
end

## Adapts the BaseController methods specific for the framework.
#class BaseController < Base
# # Queues the block call, so that it is only gets executed in the main thread.
# def queue(&block)
# end
#end

# Adapter Template for the BaseApp methods specific for the framework.
class App < Base

def initialize(opts={}, &blk)
end

# Returns the framework_adapter for this class.
def framework_adapter
framework_adapter_for('App')
end


# Runs the application, starting anything the framework needs.
def run
end

# Refreshes the GUI application, running just one event loop.
#
# This method is mostly useful when writing tests. It shouldn't be used
# in normal applications.
def refresh
end

# Exits the application, freeing any resources used by the framework.
def quit
end
end

## Adapts the BaseModel methods specific for the framework
#class BaseElement < Base
#end

# Adapts the BaseView methods specific for the framework
class BaseNative < Base
# Queues the block call, so that it is only gets executed in the main thread.
def queue(&block)
end

# Adds a widget to the given container widget.
def add_widget_to_container(widget, container_widget)
end

# Removes a widget from the given container widget.
def remove_widget_from_container(widget, container_widget)
end

# Removes all children from the given container widget.
def remove_all_children(container_widget)
end

# Sets the widget name for the given widget if given.
def set_widget_name(widget, widget_name)
end

# Autoconnects signals handlers for the view. If +other_target+ is given
# it is used instead of the view itself.
def autoconnect_signals(view, other_target = nil)
end

# Connects the signal from the widget to the given receiver block.
# The block is executed in the context of the receiver.
def connect_declared_signal_block(widget, signal, receiver, block)
end

# Connects the signal from the widget to the given receiver method.
def connect_declared_signal(widget, signal, receiver, method)
end

# Builds widgets from the given filename, using the proper builder.
def build_widgets_from(filename)
end

# Registers widgets as attributes of the view class.
def register_widgets
end

class << self
# Returns the builder file extension to be used for this view class.
def builder_file_extension
end
end
end

## Adapts the BaseViewHelper methods specific for the framework
#class BaseViewHelper
#end
end
end

20 changes: 20 additions & 0 deletions archive/button.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Shoes
class Button < Native

attr_accessor :button

def initialize(parent,opts={}, &blk)
super(opts)
opts[:text] ||= "Button"
@button = javax.swing.JButton.new(opts[:text])
@button.add_action_listener(&blk) unless blk.nil?
parent.add(@button)
return @button
end

def to_java
@button.to_java
end

end
end
36 changes: 36 additions & 0 deletions archive/shoes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'java'

require 'rubygems'
require 'facets/hash'

require 'swt'

require 'lib/log4j/log4j-1.2.16.jar'
require 'log4jruby'
require 'log4jruby/logger_for_class'
logger = Log4jruby::Logger.get('test', :tracing => true, :level => :debug )
logger.debug("Shoooes!")

require 'swt_shoes/app'
#require 'swt_shoes/element_methods'
require 'swt_shoes/layout'
#require 'swt_shoes/native'
require 'swt_shoes/window'
#require 'swt_shoes/flow'
#require 'swt_shoes/button'
#require 'swt_shoes/animation'

module Shoes

include Log4jruby::LoggerForClass

def self.app(opts={}, &blk)
Shoes::App.new(opts, &blk)
logger.debug "Exiting Shoes.app"
end

end

def window(*a, &b)
Shoes.app(*a, &b)
end
File renamed without changes.
File renamed without changes.
60 changes: 60 additions & 0 deletions archive/spec_brown_shoes/element_methods_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Basic Element Methods" do

before(:all) do
@gui = Shoes.app do


button :text => "Change to Hello", :id => 'button_one'

button :text => 'Change to Goodbye', :id => 'button_two'

end
end

it "Should return 0 for left for button_one" do
@gui.elements['button_one'].left.should be 0
end

it "Should return 0 for top of button_one" do
@gui.elements['button_one'].top.should be 0
end

it "Should return 0 for left for button_two" do
@gui.elements['button_two'].left.should be 0
end

it "Should return 0 for top for button_two" do
@gui.elements['button_two'].top.should be 147
end

it "Should make button_one invisible when hide is called" do
@gui.elements['button_one'].hide
@gui.elements['button_one'].to_java.isVisible.should be false
end

it "Should make button_one visible when show is called" do
@gui.elements['button_one'].hide
@gui.elements['button_one'].show
@gui.elements['button_one'].to_java.isVisible.should be true
end

it "Should make button_one hidden when toggle is called and it is visible" do
@gui.elements['button_one'].show
@gui.elements['button_one'].toggle
@gui.elements['button_one'].to_java.isVisible.should be false
end

it "Should make button_one visible after being hidden when toggle is called and it is hidden" do
@gui.elements['button_one'].hide
@gui.elements['button_one'].toggle
@gui.elements['button_one'].to_java.isVisible.should be true
end


after(:all) do
@gui.frame.dispose()
end

end
File renamed without changes.
37 changes: 37 additions & 0 deletions archive/spec_brown_shoes/flow_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require "spec_brown_helper"
import javax.swing.JPanel
import javax.swing.border.EmptyBorder

describe Shoes::Flow do

let(:parent_container) { JPanel.new }

it "should have a container as JPanel" do
flow = Shoes::Flow.new(parent_container)
flow.parent_container.should == parent_container
flow.container.should be_a JPanel
flow.container.should_not === flow.parent_container
end

it "should horizontally stack 3 widgets" do
button1 = button2 = button3 = nil
tflow = Shoes::Flow.new(parent_container) do
button1 = button("Button1")
button2 = button("Button2")
button3 = button("Button3")
end
debugger
button1.left.should >= 0
button2.left.should > 0
button2.left.should >= button1.left + button1.width
end

it "should have a margin" do
button1 = nil
flow = Shoes::Flow.new(parent_container, :margin => 10)

flow.container.border.should be_a EmptyBorder
flow.container.border.border_insets.left.should == 10
end

end
File renamed without changes.
Binary file added archive/spec_brown_shoes/images/shoe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions archive/spec_brown_shoes/native_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "spec_helper"

describe Shoes::Native do

it "should do something" do
end
end
35 changes: 35 additions & 0 deletions archive/window.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#require 'shoes/framework_adapters/swt_shoes/layout'

module SwtShoes
class Window < Layout

DEFAULT_WIDTH = 800
DEFAULT_HEIGHT = 600
DEFAULT_TITLE = "Shooes!"

attr_reader :container

def initialize(opts = {}, &blk)
opts.stringify_keys!
@elements = opts['elements']

@container = Swt::Widgets::Shell.new($display, Swt::SWT::CLOSE)

width, height = opts['width'] || DEFAULT_WIDTH, opts['height'] || DEFAULT_HEIGHT

@container.setSize(width, height)
@container.setText(opts['title'] || DEFAULT_TITLE)

if opts['on_close']
logger.debug "Shell #{@container.inspect} adding block #{blk.inspect}"
@container.addListener(Swt::SWT::Close, opts['on_close'])
end

instance_eval &blk if block_given?
#@container.pack

@container.open
end

end
end
11 changes: 8 additions & 3 deletions lib/shoes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
require 'lib/log4j/log4j-1.2.16.jar'
require 'log4jruby'
require 'log4jruby/logger_for_class'
logger = Log4jruby::Logger.get('test', :tracing => true, :level => :debug )
logger.debug("Shoooes!")

module Shoes
attr_accessor :logger

@logger = Log4jruby::Logger.get('test', :tracing => true, :level => :debug)
@logger.debug("Shoooes!")
end

require 'shoes/app'
#require 'shoes/native'
Expand All @@ -18,7 +23,7 @@
#require 'shoes/layout'
#require 'shoes/button'
#require 'shoes/stack'
#require 'shoes/flow'
require 'shoes/flow'
#require 'shoes/edit_line'
#require 'shoes/edit_box'
#require 'shoes/check'
Expand Down
Loading

0 comments on commit 3d6d098

Please sign in to comment.