From e390893b9105fc1051c5a07b1f65bcf147fd988a Mon Sep 17 00:00:00 2001 From: Patrick Plenefisch Date: Wed, 2 Jan 2013 11:00:10 -0500 Subject: [PATCH] Renaming back to JRubyFX --- Gemfile | 2 +- Getting Started.md | 32 +++++++++---------- README.md | 12 +++---- Rakefile | 12 +++---- bin/rubyfx-generator | 4 +-- jrubyfxml.gemspec => jrubyfx.gemspec | 6 ++-- lib/{jrubyfxml.rb => jrubyfx.rb} | 4 +-- lib/jrubyfx/core_ext/observable_value.rb | 2 +- lib/jrubyfx/dsl.rb | 4 +-- lib/jrubyfx/fxml_application.rb | 4 +-- lib/jrubyfx/fxml_controller.rb | 4 +-- lib/jrubyfx/fxml_module.rb | 4 +-- lib/jrubyfx/java_fx_impl.rb | 4 +-- lib/jrubyfx/jfx_imports.rb | 2 +- lib/jrubyfx/utils.rb | 2 +- lib/{jrubyfxml_tasks.rb => jrubyfx_tasks.rb} | 8 ++--- samples/contrib/fxmlexample/FXMLExample.rb | 2 +- .../fxmlexample/FXMLExampleController.rb | 2 +- samples/fxml/Demo.rb | 10 +++--- samples/javafx/analog_clock.rb | 2 +- samples/javafx/binding_app.rb | 2 +- samples/javafx/hello_devoxx.rb | 2 +- samples/javafx/hello_jrubyfx.rb | 2 +- samples/javafx/line_chart.rb | 2 +- samples/javafx/movie_app.rb | 2 +- samples/javafx/table_app.rb | 2 +- 26 files changed, 67 insertions(+), 67 deletions(-) rename jrubyfxml.gemspec => jrubyfx.gemspec (85%) rename lib/{jrubyfxml.rb => jrubyfx.rb} (94%) rename lib/{jrubyfxml_tasks.rb => jrubyfx_tasks.rb} (94%) diff --git a/Gemfile b/Gemfile index 72a6afe..14c865a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in JRubyFXML.gemspec +# Specify your gem's dependencies in JRubyFX.gemspec gemspec diff --git a/Getting Started.md b/Getting Started.md index 199ea60..80bcb97 100644 --- a/Getting Started.md +++ b/Getting Started.md @@ -1,27 +1,27 @@ -Using JRubyFXML +Using JRubyFX =============== This guide assumes you have basic knowledge of Ruby, and have JRuby 1.7 or greater and Java 7u6 or greater installed. Java 6 will also work if you are on Windows and download JavaFX runtime separately and put its path in JFX_DIR enviroment variable. At the moment, OpenJDK will unfortunatly not work as it does not have JavaFX. -Installing JRubyFXML +Installing JRubyFX -------------------- -The first thing you need to do is to install the JRubyFXML gem. Currently it is not on any gem sites, so you must do this manually, but don't worry, its easy. +The first thing you need to do is to install the JRubyFX gem. Currently it is not on any gem sites, so you must do this manually, but don't worry, its easy. The first thing we need to install is rake and bundler: $ gem install rake bundler -Now we can clone the JRubyFXML sources and install them: +Now we can clone the JRubyFX sources and install them: - $ git clone https://github.com/byteit101/JRubyFXML - $ cd JRubyFXML + $ git clone https://github.com/byteit101/JRubyFX + $ cd JRubyFX $ rake install -Success! JRubyFXML should be installed now! +Success! JRubyFX should be installed now! -Creating your first JRubyFXML application +Creating your first JRubyFX application ----------------------------------------- Lets creating a JavaFX app that has the text "Hello World". -Create a new ruby file (this tutorial will call it `hello.rb`). To use JRubyFXML, we must require it in ruby, so add `require 'jrubyfxml'` at the top of the file. Now since JavaFX was originally for Java, we must create a class that inherits from `javafx.application.Application`, however using it raw is no fun, so inherit from the ruby class `FXApplication` to gain ruby's super power. +Create a new ruby file (this tutorial will call it `hello.rb`). To use JRubyFX, we must require it in ruby, so add `require 'jrubyfx'` at the top of the file. Now since JavaFX was originally for Java, we must create a class that inherits from `javafx.application.Application`, however using it raw is no fun, so inherit from the ruby class `FXApplication` to gain ruby's super power. class HelloWorldApp < FXApplication end @@ -50,7 +50,7 @@ Wait, what? Nothing happened! We never actually launched the app, we only define Code listing so far: - require 'jrubyfxml' + require 'jrubyfx' class HelloWorldApp < FXApplication def start(stage) @@ -64,14 +64,14 @@ Code listing so far: HelloWorldApp.launch ### Adding a bit of text -Cool, we made an empty window, but usually you want something in it. Lets add a label that says "Hello World!". There are three ways to do everything in JRubyFXML: the straight-up Java way, the generic JRubyFXML way, and using a specific DSL (Domain Specific Language). As it sounds like, the Java way is basically copy-paste Java style, and the RubyFXML way is much more elegant, though its good to know both. +Cool, we made an empty window, but usually you want something in it. Lets add a label that says "Hello World!". There are three ways to do everything in JRubyFX: the straight-up Java way, the generic JRubyFX way, and using a specific DSL (Domain Specific Language). As it sounds like, the Java way is basically copy-paste Java style, and the RubyFXML way is much more elegant, though its good to know both. #### Creating a Label the Java way label = Label.new() label.text = "Hello World!" -#### Creating a Label the JRubyFXML way +#### Creating a Label the JRubyFX way label = build(Label, text: "Hello World!") @@ -83,7 +83,7 @@ Whoa! So what does `build` do? Build takes a name of a class (`Label`), creates For this single contrived example, it makes no sense, but for certain things (like animations and file save dialogs), it can save some serious typing. -#### Creating a Label the JRubyFXML DSL way +#### Creating a Label the JRubyFX DSL way The DSL is very similar to the `build` way: label_variable = label(text: "Hello World!") @@ -175,7 +175,7 @@ In the Scene Builder, drag a `Button` onto the surface of the designer, and clic Now, to change the text of the label, we must somehow get access to the label in code. To do this, we must set the `fx:id` property on it (first at the top of the properties pane). Set the `fx:id` value to "helloLabel" and save the FXML file. -**WARNING:** JavaFX has an fx:id property and a normal id property. For JRubyFXML to work, id must not be set (defaults to fx:id), or it must be the same as fx:id. +**WARNING:** JavaFX has an fx:id property and a normal id property. For JRubyFX to work, id must not be set (defaults to fx:id), or it must be the same as fx:id. ### Creating our controller In the code, we need to create a new class that inherits from FXController @@ -249,7 +249,7 @@ Code listing for Hello.fxml: Code listing for Hello.rb: - require 'jrubyfxml' + require 'jrubyfx' class HelloWorldApp < FXApplication def start(stage) @@ -271,7 +271,7 @@ Code listing for Hello.rb: Now what? --------- -Now you know the basics of FXML and JRubyFXML! If you haven't already, I suggest looking over samples/fxml/Demo.rb for a bit more detail. JavaFX help is all around, and most of it is applicable to JRubyFXML. +Now you know the basics of FXML and JRubyFX! If you haven't already, I suggest looking over samples/fxml/Demo.rb for a bit more detail. JavaFX help is all around, and most of it is applicable to JRubyFX. ### Using the generator Got a large FXML file with dozens of fx:id's and events? Assuming you only have a FXML file: diff --git a/README.md b/README.md index 63807bc..f7e2654 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -JRubyFXML +JRubyFX ======= -JRubyFXML is a pure ruby wrapper for JavaFX 2.x with FXML support (based on JRubyFX) +JRubyFX is a pure ruby wrapper for JavaFX 2.x with FXML support (based on JRubyFX) Status ------ -JRubyFXML should be usable in its current form and able to run FXML apps if used properly (see Issues). -The syntax of the FXML side of JRubyFXML should be fairly stable, but the JavaFX DSL may change. +JRubyFX should be usable in its current form and able to run FXML apps if used properly (see Issues). +The syntax of the FXML side of JRubyFX should be fairly stable, but the JavaFX DSL may change. At this point in time, no custom ruby controls are supported from FXML, though you can certainly create them in code. @@ -43,7 +43,7 @@ To run sample: jruby samples/fxml/Demo.rb ``` -Or, if you have not installed the gem, or are testing edits to jrubyfxml.rb: +Or, if you have not installed the gem, or are testing edits to jrubyfx.rb: ```text rake run main_script=samples/fxml/Demo.rb @@ -52,7 +52,7 @@ rake run main_script=samples/fxml/Demo.rb Creating Application and Controller ----------------------------------- -Import jrubyfxml file, and subclass FXApplication and FXController. +Import jrubyfx file, and subclass FXApplication and FXController. At the bottom of the file, call _yourFXApplicationClass_.launch(). Override start(stage) in the application, and initialize(url, resources) in the controller. See samples/fxml/Demo.rb for commented example, or see the Getting Started guide diff --git a/Rakefile b/Rakefile index 21f178c..48648c7 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2012 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -19,7 +19,7 @@ require 'rubygems' require 'rubygems/installer' require 'rubygems/package_task' require 'rdoc/task' -require_relative 'lib/jrubyfxml_tasks' +require_relative 'lib/jrubyfx_tasks' task :default => [:build, :run] jar = ENV['jar'] || "jar" @@ -49,7 +49,7 @@ task :run do ruby "-I lib '#{main_script||'samples/fxml/Demo.rb'}'" end -load 'jrubyfxml.gemspec' +load 'jrubyfx.gemspec' Gem::PackageTask.new($spec) do |pkg| pkg.need_zip = false pkg.need_tar = false @@ -57,7 +57,7 @@ end desc "Build and install the gem" task :install => :gem do - Gem::Installer.new("pkg/jrubyfxml-#{JRubyFX::VERSION}-java.gem").install + Gem::Installer.new("pkg/jrubyfx-#{JRubyFX::VERSION}-java.gem").install end task :download_jruby_jar do @@ -66,7 +66,7 @@ end desc "Create a full jar with embedded JRuby and given script (via main_script and src ENV var)" task :jar => [:clean, :download_jruby_jar] do - JRubyFX::Tasks::jarify_jrubyfxml(src, main_script, target, output_jar, jar) + JRubyFX::Tasks::jarify_jrubyfx(src, main_script, target, output_jar, jar) end desc "Create a full jar and run it" @@ -78,6 +78,6 @@ RDoc::Task.new do |rdoc| files = ['lib'] # FIXME: readme and markdown rdoc.rdoc_files.add(files) rdoc.main = "README.md" - rdoc.title = "JRubyFXML Docs" + rdoc.title = "JRubyFX Docs" rdoc.rdoc_dir = 'doc/' end diff --git a/bin/rubyfx-generator b/bin/rubyfx-generator index df2ee37..199bb09 100755 --- a/bin/rubyfx-generator +++ b/bin/rubyfx-generator @@ -1,6 +1,6 @@ #!/usr/bin/env jruby =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2012 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -39,7 +39,7 @@ File.open(rb, "w") do |output| output << <. =end require 'java' -require 'jrubyfxml' +require 'jrubyfx' module JRubyFX # Defines a nice DSL for building JavaFX applications. Include it in a class for diff --git a/lib/jrubyfx/fxml_application.rb b/lib/jrubyfx/fxml_application.rb index 3bbf667..f819a7a 100644 --- a/lib/jrubyfx/fxml_application.rb +++ b/lib/jrubyfx/fxml_application.rb @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2013 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ along with this program. If not, see . =end -require 'jrubyfxml' +require 'jrubyfx' ## # Inherit from this class for FXML Applications. You must use this class for both diff --git a/lib/jrubyfx/fxml_controller.rb b/lib/jrubyfx/fxml_controller.rb index 4f7a6e3..001fc47 100644 --- a/lib/jrubyfx/fxml_controller.rb +++ b/lib/jrubyfx/fxml_controller.rb @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2013 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ along with this program. If not, see . =end -require 'jrubyfxml' +require 'jrubyfx' # Inherit from this class for FXML controllers class FXController diff --git a/lib/jrubyfx/fxml_module.rb b/lib/jrubyfx/fxml_module.rb index 9c8eee4..4998f11 100644 --- a/lib/jrubyfx/fxml_module.rb +++ b/lib/jrubyfx/fxml_module.rb @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2012 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ along with this program. If not, see . =end -require 'jrubyfxml' +require 'jrubyfx' require 'jrubyfx/utils/common_utils' # This module contains useful methods for defining JavaFX code. Include it in your diff --git a/lib/jrubyfx/java_fx_impl.rb b/lib/jrubyfx/java_fx_impl.rb index 9852674..fe28a9e 100644 --- a/lib/jrubyfx/java_fx_impl.rb +++ b/lib/jrubyfx/java_fx_impl.rb @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2013 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ along with this program. If not, see . =end #:nodoc: all -require 'jrubyfxml' +require 'jrubyfx' # Due to certain bugs in JRuby 1.7 (namely some newInstance mapping bugs), we # are forced to re-create the Launcher if we want a pure ruby wrapper diff --git a/lib/jrubyfx/jfx_imports.rb b/lib/jrubyfx/jfx_imports.rb index c59c0fa..dc4858e 100644 --- a/lib/jrubyfx/jfx_imports.rb +++ b/lib/jrubyfx/jfx_imports.rb @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2012 Patrick Plenefisch This program is free software: you can redistribute it and/or modify diff --git a/lib/jrubyfx/utils.rb b/lib/jrubyfx/utils.rb index 127ad35..8d5ab61 100644 --- a/lib/jrubyfx/utils.rb +++ b/lib/jrubyfx/utils.rb @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2012 Patrick Plenefisch This program is free software: you can redistribute it and/or modify diff --git a/lib/jrubyfxml_tasks.rb b/lib/jrubyfx_tasks.rb similarity index 94% rename from lib/jrubyfxml_tasks.rb rename to lib/jrubyfx_tasks.rb index 2d34f61..89658e4 100644 --- a/lib/jrubyfxml_tasks.rb +++ b/lib/jrubyfx_tasks.rb @@ -1,5 +1,5 @@ =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2012 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -50,9 +50,9 @@ def download_jruby(jruby_version, force=false) # temporary work dir. `jar` is the executable that makes jars. If `target` is # nill then a random temporary directory is created, and output_jar is the # full path to the jar file to save - def jarify_jrubyfxml(src="src/*" ,main_script=nil, target="target", output_jar="jrubyfx-app.jar", jar="jar") + def jarify_jrubyfx(src="src/*" ,main_script=nil, target="target", output_jar="jrubyfx-app.jar", jar="jar") if target_was_nil = target == nil - target = Dir.mktmpdir("jrubyfxml") + target = Dir.mktmpdir("jrubyfx") final_jar = output_jar output_jar = File.basename output_jar end @@ -101,7 +101,7 @@ def download(version_string) #:nodoc: end end - module_function :jarify_jrubyfxml + module_function :jarify_jrubyfx module_function :download_jruby module_function :download end diff --git a/samples/contrib/fxmlexample/FXMLExample.rb b/samples/contrib/fxmlexample/FXMLExample.rb index 279ab61..566c101 100755 --- a/samples/contrib/fxmlexample/FXMLExample.rb +++ b/samples/contrib/fxmlexample/FXMLExample.rb @@ -34,7 +34,7 @@ */ =end -require 'jrubyfxml' +require 'jrubyfx' require_relative 'FXMLExampleController' class FXMLExample < FXApplication diff --git a/samples/contrib/fxmlexample/FXMLExampleController.rb b/samples/contrib/fxmlexample/FXMLExampleController.rb index 84729b5..37074ab 100644 --- a/samples/contrib/fxmlexample/FXMLExampleController.rb +++ b/samples/contrib/fxmlexample/FXMLExampleController.rb @@ -33,7 +33,7 @@ */ =end -require 'jrubyfxml' +require 'jrubyfx' class FXMLExampleController < FXController # you can comma separate them, or provide multiple definitions diff --git a/samples/fxml/Demo.rb b/samples/fxml/Demo.rb index 772e41d..9dab140 100755 --- a/samples/fxml/Demo.rb +++ b/samples/fxml/Demo.rb @@ -1,6 +1,6 @@ #!/usr/bin/env jruby =begin -JRubyFXML - Write JavaFX and FXML in Ruby +JRubyFX - Write JavaFX and FXML in Ruby Copyright (C) 2013 Patrick Plenefisch This program is free software: you can redistribute it and/or modify @@ -17,8 +17,8 @@ along with this program. If not, see . =end -# Require JRubyFXML library so we can get FXApplication and FXController -require 'jrubyfxml' +# Require JRubyFX library so we can get FXApplication and FXController +require 'jrubyfx' # Inherit from FXApplication to create our Application class SimpleFXApplication < FXApplication @@ -102,12 +102,12 @@ def initialize(first, second) # Note that JavaFX does not add extensions automatically, so lets add it output_jar += ".jar" unless output_jar.end_with? ".jar" # import the jarification tasks - require 'jrubyfxml_tasks' + require 'jrubyfx_tasks' # Download jruby (current version running) JRubyFXTasks::download_jruby(JRUBY_VERSION) # Create a jar of all file in this same folder, this file is the root script, # no fixed staging dir, and save it to our file we specified - JRubyFXTasks::jarify_jrubyfxml("#{File.dirname(__FILE__)}/*", __FILE__, nil, output_jar) + JRubyFXTasks::jarify_jrubyfx("#{File.dirname(__FILE__)}/*", __FILE__, nil, output_jar) puts "Success!" end end diff --git a/samples/javafx/analog_clock.rb b/samples/javafx/analog_clock.rb index 267caac..c4d6c75 100755 --- a/samples/javafx/analog_clock.rb +++ b/samples/javafx/analog_clock.rb @@ -1,5 +1,5 @@ #!/usr/bin/env jruby -require 'jrubyfxml' +require 'jrubyfx' class AnalogClock < FXApplication diff --git a/samples/javafx/binding_app.rb b/samples/javafx/binding_app.rb index 1152bd1..d1ef822 100755 --- a/samples/javafx/binding_app.rb +++ b/samples/javafx/binding_app.rb @@ -1,5 +1,5 @@ #!/usr/bin/env jruby -require 'jrubyfxml' +require 'jrubyfx' class BindingApp < FXApplication diff --git a/samples/javafx/hello_devoxx.rb b/samples/javafx/hello_devoxx.rb index 4ffcc5e..8edcfe7 100755 --- a/samples/javafx/hello_devoxx.rb +++ b/samples/javafx/hello_devoxx.rb @@ -1,7 +1,7 @@ #!/usr/bin/env jruby # Original version is here: http://www.slideshare.net/steveonjava/java-fx-20-a-developers-guide -require 'jrubyfxml' +require 'jrubyfx' class HelloDevoxx < FXApplication diff --git a/samples/javafx/hello_jrubyfx.rb b/samples/javafx/hello_jrubyfx.rb index 9ff3ff2..12dc83f 100755 --- a/samples/javafx/hello_jrubyfx.rb +++ b/samples/javafx/hello_jrubyfx.rb @@ -2,7 +2,7 @@ # Original version is here: http://www.oracle.com/technetwork/jp/ondemand/java/20110519-java-a-2-sato-400530-ja.pdf # Modified by Hiroshi Nakamura -require 'jrubyfxml' +require 'jrubyfx' class HelloJRubyFX < FXApplication diff --git a/samples/javafx/line_chart.rb b/samples/javafx/line_chart.rb index d5bd84b..29d5ada 100755 --- a/samples/javafx/line_chart.rb +++ b/samples/javafx/line_chart.rb @@ -1,5 +1,5 @@ #!/usr/bin/env jruby -require 'jrubyfxml' +require 'jrubyfx' class LineChart < FXApplication diff --git a/samples/javafx/movie_app.rb b/samples/javafx/movie_app.rb index 6e7577c..6e13218 100755 --- a/samples/javafx/movie_app.rb +++ b/samples/javafx/movie_app.rb @@ -2,7 +2,7 @@ # Original version is for GroovyFX by @kazuchika # https://gist.github.com/1362259G -require 'jrubyfxml' +require 'jrubyfx' class MovieApp < FXApplication include JRubyFX::DSL diff --git a/samples/javafx/table_app.rb b/samples/javafx/table_app.rb index 5ed3090..c717aa2 100755 --- a/samples/javafx/table_app.rb +++ b/samples/javafx/table_app.rb @@ -1,6 +1,6 @@ #!/usr/bin/env jruby # Original version is here: http://drdobbs.com/blogs/java/231903245 (BindingEx1) -require 'jrubyfxml' +require 'jrubyfx' class TableApp < FXApplication