Neurogami-jimpanzee 1.0.2.1
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.txt +3 -0
- data/Jimpanzee.gemspec +0 -0
- data/Manifest.txt +62 -0
- data/README.md +23 -0
- data/Rakefile +98 -0
- data/bin/jimpanzee +41 -0
- data/lib/monkeybars.rb +7 -0
- data/lib/monkeybars/controller.rb +608 -0
- data/lib/monkeybars/debug.rb +69 -0
- data/lib/monkeybars/event_handler.rb +89 -0
- data/lib/monkeybars/event_handler_registration_and_dispatch_mixin.rb +251 -0
- data/lib/monkeybars/exceptions.rb +10 -0
- data/lib/monkeybars/global_error_handler.rb +34 -0
- data/lib/monkeybars/inflector.rb +68 -0
- data/lib/monkeybars/key.rb +206 -0
- data/lib/monkeybars/task_processor.rb +47 -0
- data/lib/monkeybars/validated_hash.rb +22 -0
- data/lib/monkeybars/view.rb +609 -0
- data/lib/monkeybars/view_mapping.rb +379 -0
- data/lib/monkeybars/view_nesting.rb +114 -0
- data/lib/monkeybars/view_positioning.rb +66 -0
- data/skeleton/Rakefile +5 -0
- data/skeleton/lib/java/README.txt +1 -0
- data/skeleton/lib/java/monkeybars-1.0.2.1.jar +0 -0
- data/skeleton/lib/ruby/README.md +1 -0
- data/skeleton/lib/ruby/README.txt +1 -0
- data/skeleton/src/application_controller.rb +4 -0
- data/skeleton/src/application_view.rb +3 -0
- data/skeleton/src/main.rb +52 -0
- data/skeleton/src/manifest.rb +58 -0
- data/skeleton/src/resolver.rb +33 -0
- data/skeleton/tasks/monkeybars.rake +89 -0
- metadata +99 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
module Monkeybars
|
2
|
+
class View
|
3
|
+
module Positioning
|
4
|
+
|
5
|
+
include_class Java::java::awt::Toolkit
|
6
|
+
|
7
|
+
# Returns a java.awt.Dimension
|
8
|
+
def screen_size
|
9
|
+
Toolkit.default_toolkit.screen_size
|
10
|
+
end
|
11
|
+
|
12
|
+
def move_to(x, y)
|
13
|
+
@main_view_component.set_location(x,y)
|
14
|
+
end
|
15
|
+
|
16
|
+
def move_to_center
|
17
|
+
x = (screen_size.width - @main_view_component.width)/2
|
18
|
+
y = (screen_size.height - @main_view_component.height)/2
|
19
|
+
move_to(x, y)
|
20
|
+
end
|
21
|
+
|
22
|
+
def move_to_top_right
|
23
|
+
move_to(right_edge_x_coordinate, 0)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def move_to_top_left
|
28
|
+
move_to(0, 0)
|
29
|
+
end
|
30
|
+
|
31
|
+
def move_to_bottom_left
|
32
|
+
move_to(0, bottom_edge_y_coordinate)
|
33
|
+
end
|
34
|
+
|
35
|
+
def move_to_bottom_right
|
36
|
+
screen_size = Toolkit.default_toolkit.screen_size
|
37
|
+
move_to(right_edge_x_coordinate, bottom_edge_y_coordinate)
|
38
|
+
end
|
39
|
+
|
40
|
+
def x
|
41
|
+
@main_view_component.location.x
|
42
|
+
end
|
43
|
+
|
44
|
+
def y
|
45
|
+
@main_view_component.location.y
|
46
|
+
end
|
47
|
+
|
48
|
+
def width
|
49
|
+
@main_view_component.width
|
50
|
+
end
|
51
|
+
|
52
|
+
def height
|
53
|
+
@main_view_component.height
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def right_edge_x_coordinate
|
58
|
+
screen_size.width - @main_view_component.width
|
59
|
+
end
|
60
|
+
|
61
|
+
def bottom_edge_y_coordinate
|
62
|
+
screen_size.height - @main_view_component.height
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/skeleton/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Place your jars here.
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
3rd party Ruby libs and unpacked gems go here.
|
@@ -0,0 +1 @@
|
|
1
|
+
3rd party Ruby libs and unpacked gems go here.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#===============================================================================
|
2
|
+
# Much of the platform specific code should be called before Swing is touched.
|
3
|
+
# The useScreenMenuBar is an example of this.
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'java'
|
6
|
+
|
7
|
+
#===============================================================================
|
8
|
+
# Platform specific operations, feel free to remove or override any of these
|
9
|
+
# that don't work for your platform/application
|
10
|
+
|
11
|
+
case Config::CONFIG["host_os"]
|
12
|
+
when /darwin/i # OSX specific code
|
13
|
+
java.lang.System.set_property("apple.laf.useScreenMenuBar", "true")
|
14
|
+
when /^win|mswin/i # Windows specific code
|
15
|
+
when /linux/i # Linux specific code
|
16
|
+
end
|
17
|
+
|
18
|
+
# End of platform specific code
|
19
|
+
#===============================================================================
|
20
|
+
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
|
21
|
+
require 'manifest'
|
22
|
+
|
23
|
+
# Set up global error handling so that it is consistantly logged or outputed
|
24
|
+
# You will probably want to replace the puts with your application's logger
|
25
|
+
def show_error_dialog_and_exit(exception, thread=nil)
|
26
|
+
puts "Error in application"
|
27
|
+
puts "#{exception.class} - #{exception}"
|
28
|
+
if exception.kind_of? Exception
|
29
|
+
puts exception.backtrace.join("\n")
|
30
|
+
else
|
31
|
+
# Workaround for JRuby issue #2673, getStackTrace returning an empty array
|
32
|
+
output_stream = java.io.ByteArrayOutputStream.new
|
33
|
+
exception.printStackTrace(java.io.PrintStream.new(output_stream))
|
34
|
+
puts output_stream.to_string
|
35
|
+
end
|
36
|
+
|
37
|
+
# Your error handling code goes here
|
38
|
+
|
39
|
+
# Show error dialog informing the user that there was an error
|
40
|
+
title = "Application Error"
|
41
|
+
message = "The application has encountered an error and must shut down."
|
42
|
+
|
43
|
+
javax.swing.JOptionPane.show_message_dialog(nil, message, title, javax.swing.JOptionPane::DEFAULT_OPTION)
|
44
|
+
java.lang.System.exit(0)
|
45
|
+
end
|
46
|
+
GlobalErrorHandler.on_error {|exception, thread| show_error_dialog_and_exit(exception, thread) }
|
47
|
+
|
48
|
+
begin
|
49
|
+
# Your application code goes here
|
50
|
+
rescue => e
|
51
|
+
show_error_dialog_and_exit(e)
|
52
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
$LOAD_PATH.clear #ensure load path is cleared so system gems and libraries are not used (only project gems/libs)
|
2
|
+
# Load current and subdirectories in src onto the load path
|
3
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
4
|
+
Dir.glob(File.expand_path(File.dirname(__FILE__) + "/**/*")).each do |directory|
|
5
|
+
# File.directory? is broken in current JRuby for dirs inside jars
|
6
|
+
# http://jira.codehaus.org/browse/JRUBY-2289
|
7
|
+
$LOAD_PATH << directory unless directory =~ /\.\w+$/
|
8
|
+
end
|
9
|
+
# Some JRuby $LOAD_PATH path bugs to check if you're having trouble:
|
10
|
+
# http://jira.codehaus.org/browse/JRUBY-2518 - Dir.glob and Dir[] doesn't work
|
11
|
+
# for starting in a dir in a jar
|
12
|
+
# (such as Active-Record migrations)
|
13
|
+
# http://jira.codehaus.org/browse/JRUBY-3247 - Compiled Ruby classes produce
|
14
|
+
# word substitutes for characters
|
15
|
+
# like - and . (to minus and dot).
|
16
|
+
# This is problematic with gems
|
17
|
+
# like ActiveSupport and Prawn
|
18
|
+
|
19
|
+
#===============================================================================
|
20
|
+
# Monkeybars requires, this pulls in the requisite libraries needed for
|
21
|
+
# Monkeybars to operate.
|
22
|
+
|
23
|
+
require 'resolver'
|
24
|
+
|
25
|
+
case Monkeybars::Resolver.run_location
|
26
|
+
when Monkeybars::Resolver::IN_FILE_SYSTEM
|
27
|
+
add_to_classpath '../lib/java/monkeybars-1.0.2.jar'
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'monkeybars'
|
31
|
+
require 'application_controller'
|
32
|
+
require 'application_view'
|
33
|
+
|
34
|
+
# End of Monkeybars requires
|
35
|
+
#===============================================================================
|
36
|
+
#
|
37
|
+
# Add your own application-wide libraries below. To include jars, append to
|
38
|
+
# $CLASSPATH, or use add_to_classpath, for example:
|
39
|
+
#
|
40
|
+
# $CLASSPATH << File.expand_path(File.dirname(__FILE__) + "/../lib/java/swing-layout-1.0.3.jar")
|
41
|
+
#
|
42
|
+
# is equivalent to
|
43
|
+
#
|
44
|
+
# add_to_classpath "../lib/java/swing-layout-1.0.3.jar"
|
45
|
+
#
|
46
|
+
# There is also a helper for adding to your load path and avoiding issues with file: being
|
47
|
+
# appended to the load path (useful for JRuby libs that need your jar directory on
|
48
|
+
# the load path).
|
49
|
+
#
|
50
|
+
# add_to_load_path "../lib/java"
|
51
|
+
#
|
52
|
+
|
53
|
+
case Monkeybars::Resolver.run_location
|
54
|
+
when Monkeybars::Resolver::IN_FILE_SYSTEM
|
55
|
+
# Files to be added only when running from the file system go here
|
56
|
+
when Monkeybars::Resolver::IN_JAR_FILE
|
57
|
+
# Files to be added only when run from inside a jar file
|
58
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Monkeybars
|
2
|
+
class Resolver
|
3
|
+
IN_FILE_SYSTEM = :in_file_system
|
4
|
+
IN_JAR_FILE = :in_jar_file
|
5
|
+
|
6
|
+
# Returns a const value indicating if the currently executing code is being run from the file system or from within a jar file.
|
7
|
+
def self.run_location
|
8
|
+
if File.expand_path(__FILE__) =~ /\.jar\!/
|
9
|
+
IN_JAR_FILE
|
10
|
+
else
|
11
|
+
IN_FILE_SYSTEM
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Object
|
18
|
+
def add_to_classpath(path)
|
19
|
+
$CLASSPATH << get_expanded_path(path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_to_load_path(path)
|
23
|
+
$LOAD_PATH << get_expanded_path(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def get_expanded_path(path)
|
28
|
+
resolved_path = File.expand_path(File.dirname(__FILE__) + "/" + path.gsub("\\", "/"))
|
29
|
+
resolved_path.gsub!("file:", "") unless resolved_path.index(".jar!")
|
30
|
+
resolved_path.gsub!("%20", ' ')
|
31
|
+
resolved_path
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
desc "ALL, CONTROLLER, VIEW, MODEL are valid options."
|
4
|
+
task 'generate'
|
5
|
+
rule(/^generate/) do |t|
|
6
|
+
ARGV[1..-1].each do |generator_command|
|
7
|
+
command, argument = generator_command.split("=")
|
8
|
+
case command
|
9
|
+
when "ALL"
|
10
|
+
generate_tuple(argument)
|
11
|
+
when "VIEW"
|
12
|
+
generate_view(argument)
|
13
|
+
when "CONTROLLER"
|
14
|
+
generate_controller(argument)
|
15
|
+
when "MODEL"
|
16
|
+
generate_model(argument)
|
17
|
+
else
|
18
|
+
$stdout << "Unknown generate target #{argument}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_tuple(path)
|
24
|
+
pwd = FileUtils.pwd
|
25
|
+
generate_controller(path)
|
26
|
+
FileUtils.cd(pwd)
|
27
|
+
generate_model(path)
|
28
|
+
FileUtils.cd(pwd)
|
29
|
+
generate_view(path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_controller(path)
|
33
|
+
name = setup_directory(path)
|
34
|
+
file_name = "#{name}_controller.rb"
|
35
|
+
name = camelize(name)
|
36
|
+
$stdout << "Generating controller #{name}Controller in file #{file_name}\n"
|
37
|
+
File.open(file_name, "w") do |controller_file|
|
38
|
+
controller_file << <<-ENDL
|
39
|
+
class #{name}Controller < ApplicationController
|
40
|
+
set_model '#{name}Model'
|
41
|
+
set_view '#{name}View'
|
42
|
+
set_close_action :exit
|
43
|
+
end
|
44
|
+
ENDL
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def generate_model(path)
|
49
|
+
name = setup_directory(path)
|
50
|
+
file_name = "#{name}_model.rb"
|
51
|
+
name = camelize(name)
|
52
|
+
$stdout << "Generating model #{name}Model in file #{file_name}\n"
|
53
|
+
File.open(file_name, "w") do |model_file|
|
54
|
+
model_file << <<-ENDL
|
55
|
+
class #{name}Model
|
56
|
+
|
57
|
+
end
|
58
|
+
ENDL
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def generate_view(path)
|
63
|
+
name = setup_directory(path)
|
64
|
+
file_name = "#{name}_view.rb"
|
65
|
+
name = camelize(name)
|
66
|
+
$stdout << "Generating view #{name}View in file #{file_name}\n"
|
67
|
+
File.open(file_name, "w") do |view_file|
|
68
|
+
view_file << <<-ENDL
|
69
|
+
class #{name}View < ApplicationView
|
70
|
+
set_java_class ''
|
71
|
+
end
|
72
|
+
ENDL
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def setup_directory(path)
|
77
|
+
FileUtils.mkdir_p path.gsub("\\", "/")
|
78
|
+
FileUtils.cd(path)
|
79
|
+
path.split("/").last
|
80
|
+
end
|
81
|
+
|
82
|
+
def camelize(name, first_letter_in_uppercase = true)
|
83
|
+
name = name.to_s
|
84
|
+
if first_letter_in_uppercase
|
85
|
+
name.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
86
|
+
else
|
87
|
+
name[0..0] + camelize(name[1..-1])
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Neurogami-jimpanzee
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Britt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-12 00:00:00 -07:00
|
13
|
+
default_executable: jimpanzee
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bones
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.5.0
|
24
|
+
version:
|
25
|
+
description: The avant-garde fork of Monkeybars
|
26
|
+
email: james@neurogami.com
|
27
|
+
executables:
|
28
|
+
- jimpanzee
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- History.txt
|
33
|
+
- Manifest.txt
|
34
|
+
- README.md
|
35
|
+
- bin/jimpanzee
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- bin/jimpanzee
|
42
|
+
- lib/monkeybars.rb
|
43
|
+
- lib/monkeybars/controller.rb
|
44
|
+
- lib/monkeybars/debug.rb
|
45
|
+
- lib/monkeybars/event_handler.rb
|
46
|
+
- lib/monkeybars/event_handler_registration_and_dispatch_mixin.rb
|
47
|
+
- lib/monkeybars/exceptions.rb
|
48
|
+
- lib/monkeybars/global_error_handler.rb
|
49
|
+
- lib/monkeybars/inflector.rb
|
50
|
+
- lib/monkeybars/key.rb
|
51
|
+
- lib/monkeybars/task_processor.rb
|
52
|
+
- lib/monkeybars/validated_hash.rb
|
53
|
+
- lib/monkeybars/view_mapping.rb
|
54
|
+
- lib/monkeybars/view_nesting.rb
|
55
|
+
- lib/monkeybars/view_positioning.rb
|
56
|
+
- lib/monkeybars/view.rb
|
57
|
+
- skeleton/tasks/monkeybars.rake
|
58
|
+
- skeleton/src/application_view.rb
|
59
|
+
- skeleton/src/main.rb
|
60
|
+
- skeleton/src/application_controller.rb
|
61
|
+
- skeleton/src/resolver.rb
|
62
|
+
- skeleton/src/manifest.rb
|
63
|
+
- skeleton/lib/java/README.txt
|
64
|
+
- skeleton/lib/java/monkeybars-1.0.2.1.jar
|
65
|
+
- skeleton/lib/ruby/README.md
|
66
|
+
- skeleton/lib/ruby/README.txt
|
67
|
+
- skeleton/Rakefile
|
68
|
+
- Jimpanzee.gemspec
|
69
|
+
has_rdoc: false
|
70
|
+
homepage: http://neurogami.com/code
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options:
|
73
|
+
- --main
|
74
|
+
- README.txt
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project: !binary |
|
92
|
+
AA==
|
93
|
+
|
94
|
+
rubygems_version: 1.2.0
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: The avante-garde fork of Monkeybars
|
98
|
+
test_files: []
|
99
|
+
|