Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

rogergl

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 java_sources
Octocat-spinner-32 lib
Octocat-spinner-32 prebuild
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 changelog
Octocat-spinner-32 input_form.gemspec
Octocat-spinner-32 swt.rb
README.md

input_form

Welcome to input_form!

Input_form was designed to ease the task of developing user interfaces. To do so, it tries to level out the distinctions of the used libraries and provide a uniform usage model and to provide build in functionality for the common taks (handling of numeric data, i18n support, binding, validation and so on). Since this framework relies on the GUI frameworks the Java environment provides, you need the latest JRuby version to use this framework.

Installing

After checking out the sources from github, change to the input_form directory and run

jruby examples/main.rb

to see some usage examples.

To install input_form as a gem run

rake install

inside the input_form directory.

I recommend to take a quick look at the MigLayout documentation before diving deeper into the input_form examples.

Instead of 'rake install' you can use the gem from the prebuild directory and run

gem install input_form-0.3.8.gem

Example

The following example shows a simple form that uses some of the functionality provided by input_form:

require 'rubygems'
require "java"
require "input_form"

module InputFormExamples

   class TestLoginForm < InputForm::Base  # Every form has to inherit from InputForm::Base

      # listen to any changes made to the form. In this example triggered by "on-key-events" from the
      # text components
      listen_to :self do
         on_change do
            enable_action :login, ((!@username.is_empty?) and (!@password.is_empty?))
         end
      end

      # login action is shared by button and menu item
      action :login, "Login" do
         on_execute do
            show_message "log me in"
         end
      end

      # define the content of this form
      def init

         menu_bar :main do
            menu :file, :title => 'Main' do
               item :login, :action => :login
            end
         end

         text :username
         text :password
         button :cb_login,  :action => :login

      end

   end

   class TestLoginFormLayout < InputForm::MigFormLayout # Every layout has to inherit from InputForm:MigFormLayout

      layout do

         property :title => "LoginTest", :position => :center, :size => [400,250]  # center the form on the main screen

         # this layout has two columns, the last column resizes automatically
         columns "[100]",      "[100, grow]"

         banner_panel :banner,
            :row_hint => "[grow]",
            :title => "Login",
            :subtitle => 'Please enter your credentials', :subtitle_color => Color::blue,
            :start_color => Color::orange, :end_color => Color::green, :vertical => true,
            :border => LineBorder.new(Color::black),
            :title_icon => "#{File.dirname(__FILE__)}/edu_mathematics.png"

         add     "Username",   :username
         add     "Password",   :password,    "[]10"                     # we want a row gap of 10 pixels
         add     _         ,   :cb_login

         # now execute some hints for the MigLayout
         hint :banner, :grow => :true, :gapbottom => 8, :spanx => 2     # spanx => 2 : the banner should cover both columns
         hint :cb_login, :align => "right, bottom"

      end

   end

end

Design Goals

This framework was build with the following goals in mind:

  • Strict separation between layout, model and controller
  • Abstraction from the used GUI library and addons
  • DSL for the layout and controller specification
  • Provide an easy way to work with data models
  • Convention over configuration
  • Allow to easely maintain a consistent look and feel throughout an application
  • Allow to define components for reuse (see the components examples for the first steps towards this direction)
  • Out of the box support for I18N (assign a resource to the InputForm::Base class or a form instance - see I18N example)

Supported Components

So far the following components are supported:

  • button => JButton
  • check => JCheckBox
  • check_list => CheckList
  • date => JXDatePicker
  • hyperlink => JXHyperlink
  • image => JXPanel with an ImagePainter
  • item => JMenuItem
  • label => JLabel
  • list => JList
  • menu_bar => JMenuBar
  • menu => JMenu
  • tabbed_pane => JTabbedPane
  • task_pane => JXTaskPaneContainer
  • progressbar => JProgressbar
  • radio => JRadioButton
  • radio_group => ButtonGroup
  • searchbar => install a SearchbarInstaller
  • combobox => JComboBox
  • spinner => JSpinner
  • table => JXTable
  • text => JTextField
  • treetable => JXTreeTable

Authors

input_from was created by Roger Gilliar.

It depends on the following libraries:

The examples uses icons from the Nuvola icon set: http://www.icon-king.com/projects/nuvola/

This gem is licenced under the GPL licence (http://www.gnu.org/licenses/gpl.html)

Something went wrong with that request. Please try again.