Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated examples

  • Loading branch information...
commit 1456092d2394debdb6371598c870b3ec01bf4bf9 1 parent d864137
@Neurogami Neurogami authored
Showing with 2,036 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +4 −0 examples/FlickrBrowser/Rakefile
  3. +92 −0 examples/FlickrBrowser/build_configuration.rb
  4. BIN  examples/FlickrBrowser/icons/monkeybars.icns
  5. BIN  examples/FlickrBrowser/icons/monkeybars.ico
  6. +1 −0  examples/FlickrBrowser/lib/java/README.txt
  7. BIN  examples/FlickrBrowser/lib/java/flickraw-0.4.4.jar
  8. BIN  examples/FlickrBrowser/lib/java/swing-layout-1.0.3.jar
  9. +1 −0  examples/FlickrBrowser/lib/ruby/README.txt
  10. +135 −0 examples/FlickrBrowser/src/FlickrBrowser.form
  11. +120 −0 examples/FlickrBrowser/src/FlickrBrowser.java
  12. +4 −0 examples/FlickrBrowser/src/application_controller.rb
  13. +3 −0  examples/FlickrBrowser/src/application_view.rb
  14. +26 −0 examples/FlickrBrowser/src/flickr_browser/flickr_browser_controller.rb
  15. +24 −0 examples/FlickrBrowser/src/flickr_browser/flickr_browser_model.rb
  16. +53 −0 examples/FlickrBrowser/src/flickr_browser/flickr_browser_view.rb
  17. +23 −0 examples/FlickrBrowser/src/main.rb
  18. +64 −0 examples/FlickrBrowser/src/manifest.rb
  19. +67 −0 examples/FlickrBrowser/src/org/rubyforge/rawr/Main.java
  20. +21 −0 examples/FlickrBrowser/src/resolver.rb
  21. +89 −0 examples/FlickrBrowser/tasks/monkeybars.rake
  22. +4 −0 examples/HelloMonkeybars/Rakefile
  23. +92 −0 examples/HelloMonkeybars/build_configuration.rb
  24. BIN  examples/HelloMonkeybars/icons/monkeybars.icns
  25. BIN  examples/HelloMonkeybars/icons/monkeybars.ico
  26. +1 −0  examples/HelloMonkeybars/lib/java/README.txt
  27. +1 −0  examples/HelloMonkeybars/lib/ruby/README.txt
  28. +51 −0 examples/HelloMonkeybars/src/Hello.form
  29. +68 −0 examples/HelloMonkeybars/src/Hello.java
  30. +4 −0 examples/HelloMonkeybars/src/application_controller.rb
  31. +3 −0  examples/HelloMonkeybars/src/application_view.rb
  32. +10 −0 examples/HelloMonkeybars/src/greeter/greeter_controller.rb
  33. +7 −0 examples/HelloMonkeybars/src/greeter/greeter_model.rb
  34. +5 −0 examples/HelloMonkeybars/src/greeter/greeter_view.rb
  35. +53 −0 examples/HelloMonkeybars/src/main.rb
  36. +61 −0 examples/HelloMonkeybars/src/manifest.rb
  37. +67 −0 examples/HelloMonkeybars/src/org/rubyforge/rawr/Main.java
  38. +33 −0 examples/HelloMonkeybars/src/resolver.rb
  39. +89 −0 examples/HelloMonkeybars/tasks/monkeybars.rake
  40. +4 −0 examples/Nested-Simple/Rakefile
  41. +92 −0 examples/Nested-Simple/build_configuration.rb
  42. BIN  examples/Nested-Simple/icons/monkeybars.icns
  43. BIN  examples/Nested-Simple/icons/monkeybars.ico
  44. +1 −0  examples/Nested-Simple/lib/java/README.txt
  45. BIN  examples/Nested-Simple/lib/java/swing-layout-1.0.3.jar
  46. +1 −0  examples/Nested-Simple/lib/ruby/README.txt
  47. +4 −0 examples/Nested-Simple/src/application_controller.rb
  48. +3 −0  examples/Nested-Simple/src/application_view.rb
  49. +82 −0 examples/Nested-Simple/src/list/ListFrame.form
  50. +77 −0 examples/Nested-Simple/src/list/ListFrame.java
  51. +33 −0 examples/Nested-Simple/src/list/list_controller.rb
  52. +3 −0  examples/Nested-Simple/src/list/list_model.rb
  53. +15 −0 examples/Nested-Simple/src/list/list_view.rb
  54. +55 −0 examples/Nested-Simple/src/main.rb
  55. +65 −0 examples/Nested-Simple/src/manifest.rb
  56. +67 −0 examples/Nested-Simple/src/org/rubyforge/rawr/Main.java
  57. +33 −0 examples/Nested-Simple/src/resolver.rb
  58. +43 −0 examples/Nested-Simple/src/search/SearchPanel.form
  59. +57 −0 examples/Nested-Simple/src/search/SearchPanel.java
  60. +20 −0 examples/Nested-Simple/src/search/search_controller.rb
  61. +7 −0 examples/Nested-Simple/src/search/search_model.rb
  62. +3 −0  examples/Nested-Simple/src/search/search_view.rb
  63. +89 −0 examples/Nested-Simple/tasks/monkeybars.rake
View
6 .gitignore
@@ -17,4 +17,10 @@ package/
skeleton/lib/java/monkeybars-0.6.4.jar
media/website/heel-server.rb
media/website/public
+# outdated-examples/FlickrBrowser/lib/java/monkeybars-1.0.6.jar
+# outdated-examples/HelloMonkeybars/lib/java/monkeybars-1.0.6.jar
+# outdated-examples/Nested-DropIn/lib/java/monkeybars-1.0.6.jar
+# outdated-examples/Nested-Rows/lib/java/monkeybars-1.0.6.jar
+# outdated-examples/Nested-Simple/lib/java/monkeybars-1.0.6.jar
+# outdated-examples/jrubydiff/lib/java/monkeybars-1.0.6.jar
View
4 examples/FlickrBrowser/Rakefile
@@ -0,0 +1,4 @@
+require 'rawr'
+Dir.glob("tasks/**/*.rake").each do |rake_file|
+ load File.expand_path(File.dirname(__FILE__) + "/" + rake_file)
+end
View
92 examples/FlickrBrowser/build_configuration.rb
@@ -0,0 +1,92 @@
+configuration do |c|
+ # The name for your resulting application file (e.g., if the project_name is 'foo' then you'll get foo.jar, foo.exe, etc.)
+ # default value: "FlickrBrowser"
+ #
+ #c.project_name = "FlickrBrowser"
+
+ # Undocumented option 'output_dir'
+ # default value: "package"
+ #
+ #c.output_dir = "package"
+
+ # The main ruby file to invoke, minus the .rb extension
+ # default value: "main"
+ #
+ #c.main_ruby_file = "main"
+
+ # The fully-qualified name of the main Java file used to initiate the application.
+ # default value: "org.rubyforge.rawr.Main"
+ #
+ #c.main_java_file = "org.rubyforge.rawr.Main"
+
+ # A list of directories where source files reside
+ # default value: ["src"]
+ #
+ #c.source_dirs = ["src"]
+
+ # A list of regexps of files to exclude
+ # default value: []
+ #
+ #c.source_exclude_filter = []
+
+ # Whether Ruby source files should be compiled into .class files
+ # default value: true
+ #
+ #c.compile_ruby_files = true
+
+ # A list of individual Java library files to include.
+ # default value: []
+ #
+ #c.java_lib_files = []
+
+ # A list of directories for rawr to include . All files in the given directories get bundled up.
+ # default value: ["lib/java"]
+ #
+ #c.java_lib_dirs = ["lib/java"]
+
+ # Undocumented option 'files_to_copy'
+ # default value: []
+ #
+ #c.files_to_copy = []
+
+ # Undocumented option 'target_jvm_version'
+ # default value: 1.6
+ #
+ #c.target_jvm_version = 1.6
+
+ # Undocumented option 'jvm_arguments'
+ # default value: ""
+ #
+ #c.jvm_arguments = ""
+
+ # Undocumented option 'java_library_path'
+ # default value: ""
+ #
+ #c.java_library_path = ""
+
+ # Undocumented option 'extra_user_jars'
+ # default value: {}
+ #
+ #c.extra_user_jars[:data] = { :directory => 'data/images/png',
+ # :location_in_jar => 'images',
+ # :exclude => /*.bak$/ }
+
+ # Undocumented option 'mac_do_not_generate_plist'
+ # default value: nil
+ #
+ #c.mac_do_not_generate_plist = nil
+
+ # Undocumented option 'mac_icon_path'
+ # default value: nil
+ #
+ #c.mac_icon_path = nil
+
+ # Undocumented option 'windows_icon_path'
+ # default value: nil
+ #
+ #c.windows_icon_path = nil
+
+ c.mac_icon_path = File.expand_path('icons/monkeybars.icns')
+ c.windows_icon_path = File.expand_path('icons/monkeybars.ico')
+end
+
View
BIN  examples/FlickrBrowser/icons/monkeybars.icns
Binary file not shown
View
BIN  examples/FlickrBrowser/icons/monkeybars.ico
Binary file not shown
View
1  examples/FlickrBrowser/lib/java/README.txt
@@ -0,0 +1 @@
+Place your jars here.
View
BIN  examples/FlickrBrowser/lib/java/flickraw-0.4.4.jar
Binary file not shown
View
BIN  examples/FlickrBrowser/lib/java/swing-layout-1.0.3.jar
Binary file not shown
View
1  examples/FlickrBrowser/lib/ruby/README.txt
@@ -0,0 +1 @@
+3rd party Ruby libs and unpacked gems go here.
View
135 examples/FlickrBrowser/src/FlickrBrowser.form
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jPanel1" max="32767" attributes="0"/>
+ <EmptySpace min="-2" pref="211" max="-2" attributes="0"/>
+ </Group>
+ <Component id="jSplitPane1" alignment="0" pref="787" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jSplitPane1" pref="384" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="search_field" min="-2" pref="404" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="go_button" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="search_field" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="go_button" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JTextField" name="search_field">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <PlainString value="jTextField1"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <PlainString value="Search"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="go_button">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <PlainString value="Go"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JSplitPane" name="jSplitPane1">
+ <Properties>
+ <Property name="dividerLocation" type="int" value="250"/>
+ <Property name="resizeWeight" type="double" value="0.25"/>
+ </Properties>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="image_label">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+ <JSplitPaneConstraints position="right"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+ <JSplitPaneConstraints position="left"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTree" name="photos_tree">
+ <Properties>
+ <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[250, 0]"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
View
120 examples/FlickrBrowser/src/FlickrBrowser.java
@@ -0,0 +1,120 @@
+/*
+ * FlickrBrowser.java
+ *
+ * Created on February 12, 2008, 6:28 PM
+ */
+
+
+
+/**
+ *
+ * @author david
+ */
+public class FlickrBrowser extends javax.swing.JFrame {
+
+ /** Creates new form FlickrBrowser */
+ public FlickrBrowser() {
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ search_field = new javax.swing.JTextField();
+ jLabel1 = new javax.swing.JLabel();
+ go_button = new javax.swing.JButton();
+ jSplitPane1 = new javax.swing.JSplitPane();
+ image_label = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ photos_tree = new javax.swing.JTree();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ search_field.setText("jTextField1");
+
+ jLabel1.setText("Search");
+
+ go_button.setText("Go");
+
+ org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(search_field, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 404, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(go_button)
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel1)
+ .add(search_field, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(go_button))
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ jSplitPane1.setDividerLocation(250);
+ jSplitPane1.setResizeWeight(0.25);
+ jSplitPane1.setRightComponent(image_label);
+
+ photos_tree.setMinimumSize(new java.awt.Dimension(250, 0));
+ jScrollPane1.setViewportView(photos_tree);
+
+ jSplitPane1.setLeftComponent(jScrollPane1);
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(211, 211, 211))
+ .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 787, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new FlickrBrowser().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton go_button;
+ private javax.swing.JLabel image_label;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JSplitPane jSplitPane1;
+ private javax.swing.JTree photos_tree;
+ private javax.swing.JTextField search_field;
+ // End of variables declaration//GEN-END:variables
+
+}
View
4 examples/FlickrBrowser/src/application_controller.rb
@@ -0,0 +1,4 @@
+class ApplicationController < Monkeybars::Controller
+ # Add content here that you want to be available to all the controllers
+ # in your application
+end
View
3  examples/FlickrBrowser/src/application_view.rb
@@ -0,0 +1,3 @@
+class ApplicationView < Monkeybars::View
+ # Add content here that you want to be available to all the views in your application
+end
View
26 examples/FlickrBrowser/src/flickr_browser/flickr_browser_controller.rb
@@ -0,0 +1,26 @@
+class FlickrBrowserController < ApplicationController
+ set_model 'FlickrBrowserModel'
+ set_view 'FlickrBrowserView'
+ set_close_action :exit
+
+ def go_button_action_performed
+ update_model(view_state.first, :search_terms)
+ model.search
+ update_view
+ end
+
+ def photos_tree_tree_will_expand(event)
+ expanding_node = event.path.last_path_component
+ transfer[:expanding_node] = expanding_node
+ transfer[:photo_sizes] = model.find_sizes_by_id(expanding_node.user_object.id)
+ signal(:expand_node)
+ end
+
+ def photos_tree_value_changed(event)
+ photo_size = event.path.last_path_component.user_object
+ if photo_size.respond_to? :source
+ transfer[:image_url] = photo_size.source.gsub(/[\\ ]/, '')
+ signal(:update_image)
+ end
+ end
+end
View
24 examples/FlickrBrowser/src/flickr_browser/flickr_browser_model.rb
@@ -0,0 +1,24 @@
+require 'flickraw'
+
+class FlickrBrowserModel
+ attr_accessor :search_terms, :search_results
+
+ def initialize
+ @search_terms = ""
+ @search_results = []
+ end
+
+ def search
+ @search_results.clear
+ unless @search_terms.empty?
+ flickr.photos.search(:text => @search_terms).each do |photo|
+ @search_results << photo
+ end
+ end
+ @search_results
+ end
+
+ def find_sizes_by_id(id)
+ flickr.photos.getSizes(:photo_id => id)
+ end
+end
View
53 examples/FlickrBrowser/src/flickr_browser/flickr_browser_view.rb
@@ -0,0 +1,53 @@
+include_class javax.swing.tree.DefaultMutableTreeNode
+include_class javax.swing.ImageIcon
+include_class java.net.URL
+
+require 'flickraw'
+
+class FlickrBrowserView < ApplicationView
+ set_java_class 'FlickrBrowser'
+
+ map :view => "photos_tree.model", :model => :search_results, :using => [:build_tree_nodes, nil]
+ map :view => "photos_tree.model.root.user_object", :model => :search_terms, :using => [:default, nil]
+ map :view => "search_field.text", :model => :search_terms
+
+ def load
+ photos_tree.model = javax.swing.tree.DefaultTreeModel.new(nil, true)
+ end
+
+ def build_tree_nodes(search_results)
+ root = DefaultMutableTreeNode.new("updating...", true)
+ search_results.each_with_index do |photo, index|
+ root.add DefaultMutableTreeNode.new(photo, true)
+ end
+ javax.swing.tree.DefaultTreeModel.new(root, true)
+ end
+
+ #define_signal :expand_node, :expand_node
+ define_signal :name => :expand_node, :handler => :expand_node
+ def expand_node(model, transfer)
+ expanding_node = transfer[:expanding_node]
+ transfer[:photo_sizes].each do |size|
+ expanding_node.add DefaultMutableTreeNode.new(size, false)
+ end
+ photos_tree.model.node_structure_changed expanding_node
+ end
+
+# define_signal :update_image, :update_image
+ define_signal :name => :update_image, :handler => :update_image
+ def update_image(model, transfer)
+ image_label.icon = ImageIcon.new(URL.new(transfer[:image_url]))
+ end
+end
+
+# Patch the FlickRaw class to return the correct value when being used as a node value
+class FlickRaw::Response
+ def to_s
+ if respond_to? :title
+ title
+ else
+ label
+ end
+ end
+
+end
View
23 examples/FlickrBrowser/src/main.rb
@@ -0,0 +1,23 @@
+$LOAD_PATH << File.dirname(__FILE__)
+Dir.glob(File.expand_path(File.dirname(__FILE__) + "/**")).each do |directory|
+ $LOAD_PATH << directory unless directory =~ /\.\w+$/ #File.directory? is broken in current JRuby for dirs inside jars
+end
+
+require 'manifest'
+require 'rbconfig'
+
+#===============================================================================
+# Platform specific operations, feel free to remove or override any of these
+# that don't work for your platform/application
+
+case Config::CONFIG["host_os"]
+when /darwin/i
+ java.lang.System.setProperty("apple.laf.useScreenMenuBar", "true")
+end
+
+# End of platform specific code
+#===============================================================================
+
+require 'flickr_browser_controller'
+
+FlickrBrowserController.instance.open
View
64 examples/FlickrBrowser/src/manifest.rb
@@ -0,0 +1,64 @@
+Dir.glob(File.expand_path(File.dirname(__FILE__) + "/**/*").gsub('%20', ' ')).each do |directory|
+ # File.directory? is broken in current JRuby for dirs inside jars
+ # http://jira.codehaus.org/browse/JRUBY-2289
+ $LOAD_PATH << directory unless directory =~ /\.\w+$/
+end
+# Some JRuby $LOAD_PATH path bugs to check if you're having trouble:
+# http://jira.codehaus.org/browse/JRUBY-2518 - Dir.glob and Dir[] doesn't work
+# for starting in a dir in a jar
+# (such as Active-Record migrations)
+# http://jira.codehaus.org/browse/JRUBY-3247 - Compiled Ruby classes produce
+# word substitutes for characters
+# like - and . (to minus and dot).
+# This is problematic with gems
+# like ActiveSupport and Prawn
+
+#===============================================================================
+# Monkeybars requires, this pulls in the requisite libraries needed for
+# Monkeybars to operate.
+
+require 'resolver'
+
+
+def monkeybars_jar path
+ Dir.glob(path).select { |f| f =~ /(monkeybars-)(.+).jar$/}.first
+end
+
+case Monkeybars::Resolver.run_location
+when Monkeybars::Resolver::IN_FILE_SYSTEM
+ here = File.expand_path File.dirname(__FILE__)
+ add_to_classpath monkeybars_jar( here + '/../lib/java/*.jar' )
+end
+
+require 'monkeybars'
+require 'application_controller'
+require 'application_view'
+
+# End of Monkeybars requires
+#===============================================================================
+#
+# Add your own application-wide libraries below. To include jars, append to
+# $CLASSPATH, or use add_to_classpath, for example:
+#
+# $CLASSPATH << File.expand_path(File.dirname(__FILE__) + "/../lib/java/swing-layout-1.0.3.jar")
+#
+# is equivalent to
+#
+# add_to_classpath "../lib/java/swing-layout-1.0.3.jar"
+#
+# There is also a helper for adding to your load path and avoiding issues with file: being
+# appended to the load path (useful for JRuby libs that need your jar directory on
+# the load path).
+#
+# add_to_load_path "../lib/java"
+#
+
+case Monkeybars::Resolver.run_location
+when Monkeybars::Resolver::IN_FILE_SYSTEM
+ # Files to be added only when running from the file system go here
+ add_to_classpath "../lib/java/flickraw-0.4.4.jar"
+ add_to_classpath "../lib/java/swing-layout-1.0.3.jar"
+ add_to_classpath "../build/classes"
+when Monkeybars::Resolver::IN_JAR_FILE
+ # Files to be added only when run from inside a jar file
+end
View
67 examples/FlickrBrowser/src/org/rubyforge/rawr/Main.java
@@ -0,0 +1,67 @@
+package org.rubyforge.rawr;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
+
+import java.util.ArrayList;
+import org.jruby.Ruby;
+import org.jruby.RubyInstanceConfig;
+import org.jruby.javasupport.JavaEmbedUtils;
+
+public class Main
+{
+ public static void main(String[] args) throws Exception
+ {
+ RubyInstanceConfig config = new RubyInstanceConfig();
+ config.setArgv(args);
+ Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
+ String mainRubyFile = "main";
+
+ ArrayList<String> config_data = new ArrayList<String>();
+ try{
+ java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
+ if (ins == null ) {
+ System.err.println("Did not find configuration file 'run_configuration', using defaults.");
+ } else {
+ config_data = getConfigFileContents(ins);
+ }
+ }
+ catch(IOException ioe)
+ {
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
+ }
+ catch(java.lang.NullPointerException npe)
+ {
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
+ }
+
+ for(String line : config_data) {
+ String[] parts = line.split(":");
+ if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
+ mainRubyFile = parts[1].replaceAll(" ", "");
+ }
+ }
+
+ runtime.evalScriptlet("require '" + mainRubyFile + "'");
+ }
+
+ public static URL getResource(String path) {
+ return Main.class.getClassLoader().getResource(path);
+ }
+
+ private static ArrayList<String> getConfigFileContents(InputStream input) throws IOException, java.lang.NullPointerException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(input));
+ String line;
+ ArrayList<String> contents = new ArrayList<String>();
+
+ while ((line = reader.readLine()) != null) {
+ contents.add(line);
+ }
+ reader.close();
+ return(contents);
+ }
+}
View
21 examples/FlickrBrowser/src/resolver.rb
@@ -0,0 +1,21 @@
+module Monkeybars
+ class Resolver
+ IN_FILE_SYSTEM = :in_file_system
+ IN_JAR_FILE = :in_jar_file
+
+ # Returns a const value indicating if the currently executing code is being run from the file system or from within a jar file.
+ def self.run_location
+ if __FILE__ =~ /\.jar\!/
+ :in_jar_file
+ else
+ :in_file_system
+ end
+ end
+ end
+end
+
+class Object
+ def add_to_classpath(path)
+ $CLASSPATH << File.expand_path(File.dirname(__FILE__) + "/" + path.gsub("\\", "/"))
+ end
+end
View
89 examples/FlickrBrowser/tasks/monkeybars.rake
@@ -0,0 +1,89 @@
+require 'fileutils'
+
+desc "ALL, CONTROLLER, VIEW, MODEL are valid options."
+task 'generate'
+rule(/^generate/) do |t|
+ ARGV[1..-1].each do |generator_command|
+ command, argument = generator_command.split("=")
+ case command
+ when "ALL"
+ generate_tuple(argument)
+ when "VIEW"
+ generate_view(argument)
+ when "CONTROLLER"
+ generate_controller(argument)
+ when "MODEL"
+ generate_model(argument)
+ else
+ $stdout << "Unknown generate target #{argument}"
+ end
+ end
+end
+
+def generate_tuple(path)
+ pwd = FileUtils.pwd
+ generate_controller(path)
+ FileUtils.cd(pwd)
+ generate_model(path)
+ FileUtils.cd(pwd)
+ generate_view(path)
+end
+
+def generate_controller(path)
+ name = setup_directory(path)
+ file_name = "#{name}_controller.rb"
+ name = camelize(name)
+ $stdout << "Generating controller #{name}Controller in file #{file_name}\n"
+ File.open(file_name, "w") do |controller_file|
+ controller_file << <<-ENDL
+class #{name}Controller < ApplicationController
+ set_model '#{name}Model'
+ set_view '#{name}View'
+ set_close_action :exit
+end
+ ENDL
+ end
+end
+
+def generate_model(path)
+ name = setup_directory(path)
+ file_name = "#{name}_model.rb"
+ name = camelize(name)
+ $stdout << "Generating model #{name}Model in file #{file_name}\n"
+ File.open(file_name, "w") do |model_file|
+ model_file << <<-ENDL
+class #{name}Model
+
+end
+ ENDL
+ end
+end
+
+def generate_view(path)
+ name = setup_directory(path)
+ file_name = "#{name}_view.rb"
+ name = camelize(name)
+ $stdout << "Generating view #{name}View in file #{file_name}\n"
+ File.open(file_name, "w") do |view_file|
+ view_file << <<-ENDL
+class #{name}View < ApplicationView
+ set_java_class ''
+end
+ ENDL
+ end
+end
+
+def setup_directory(path)
+ FileUtils.mkdir_p path.gsub("\\", "/")
+ FileUtils.cd(path)
+ path.split("/").last
+end
+
+def camelize(name, first_letter_in_uppercase = true)
+ name = name.to_s
+ if first_letter_in_uppercase
+ name.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
+ else
+ name[0..0] + camelize(name[1..-1])
+ end
+end
View
4 examples/HelloMonkeybars/Rakefile
@@ -0,0 +1,4 @@
+require 'rawr'
+Dir.glob("tasks/**/*.rake").each do |rake_file|
+ load File.expand_path(File.dirname(__FILE__) + "/" + rake_file)
+end
View
92 examples/HelloMonkeybars/build_configuration.rb
@@ -0,0 +1,92 @@
+configuration do |c|
+ # The name for your resulting application file (e.g., if the project_name is 'foo' then you'll get foo.jar, foo.exe, etc.)
+ # default value: "HelloMonkeybars"
+ #
+ #c.project_name = "HelloMonkeybars"
+
+ # Undocumented option 'output_dir'
+ # default value: "package"
+ #
+ #c.output_dir = "package"
+
+ # The main ruby file to invoke, minus the .rb extension
+ # default value: "main"
+ #
+ #c.main_ruby_file = "main"
+
+ # The fully-qualified name of the main Java file used to initiate the application.
+ # default value: "org.rubyforge.rawr.Main"
+ #
+ #c.main_java_file = "org.rubyforge.rawr.Main"
+
+ # A list of directories where source files reside
+ # default value: ["src"]
+ #
+ #c.source_dirs = ["src"]
+
+ # A list of regexps of files to exclude
+ # default value: []
+ #
+ #c.source_exclude_filter = []
+
+ # Whether Ruby source files should be compiled into .class files
+ # default value: true
+ #
+ #c.compile_ruby_files = true
+
+ # A list of individual Java library files to include.
+ # default value: []
+ #
+ #c.java_lib_files = []
+
+ # A list of directories for rawr to include . All files in the given directories get bundled up.
+ # default value: ["lib/java"]
+ #
+ #c.java_lib_dirs = ["lib/java"]
+
+ # Undocumented option 'files_to_copy'
+ # default value: []
+ #
+ #c.files_to_copy = []
+
+ # Undocumented option 'target_jvm_version'
+ # default value: 1.6
+ #
+ #c.target_jvm_version = 1.6
+
+ # Undocumented option 'jvm_arguments'
+ # default value: ""
+ #
+ #c.jvm_arguments = ""
+
+ # Undocumented option 'java_library_path'
+ # default value: ""
+ #
+ #c.java_library_path = ""
+
+ # Undocumented option 'extra_user_jars'
+ # default value: {}
+ #
+ #c.extra_user_jars[:data] = { :directory => 'data/images/png',
+ # :location_in_jar => 'images',
+ # :exclude => /*.bak$/ }
+
+ # Undocumented option 'mac_do_not_generate_plist'
+ # default value: nil
+ #
+ #c.mac_do_not_generate_plist = nil
+
+ # Undocumented option 'mac_icon_path'
+ # default value: nil
+ #
+ #c.mac_icon_path = nil
+
+ # Undocumented option 'windows_icon_path'
+ # default value: nil
+ #
+ #c.windows_icon_path = nil
+
+ c.mac_icon_path = File.expand_path('icons/monkeybars.icns')
+ c.windows_icon_path = File.expand_path('icons/monkeybars.ico')
+end
+
View
BIN  examples/HelloMonkeybars/icons/monkeybars.icns
Binary file not shown
View
BIN  examples/HelloMonkeybars/icons/monkeybars.ico
Binary file not shown
View
1  examples/HelloMonkeybars/lib/java/README.txt
@@ -0,0 +1 @@
+Place your jars here.
View
1  examples/HelloMonkeybars/lib/ruby/README.txt
@@ -0,0 +1 @@
+3rd party Ruby libs and unpacked gems go here.
View
51 examples/HelloMonkeybars/src/Hello.form
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,96,0,0,1,17"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[273, 96]"/>
+ </Property>
+ </Properties>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="message">
+ <Properties>
+ <Property name="horizontalAlignment" type="int" value="0"/>
+ <Property name="text" type="java.lang.String" value="Message goes here"/>
+ <Property name="horizontalTextPosition" type="int" value="0"/>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[300, 36]"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="improve_button">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Improve"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
View
68 examples/HelloMonkeybars/src/Hello.java
@@ -0,0 +1,68 @@
+/*
+ * Hello.java
+ *
+ * Created on March 29, 2008, 7:41 PM
+ */
+
+
+
+/**
+ *
+ * @author david
+ */
+public class Hello extends javax.swing.JFrame {
+
+ /** Creates new form Hello */
+ public Hello() {
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ message = new javax.swing.JLabel();
+ improve_button = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
+
+ jPanel1.setPreferredSize(new java.awt.Dimension(273, 96));
+
+ message.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ message.setText("Message goes here");
+ message.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ message.setPreferredSize(new java.awt.Dimension(300, 36));
+ jPanel1.add(message);
+
+ improve_button.setText("Improve");
+ jPanel1.add(improve_button);
+
+ getContentPane().add(jPanel1);
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new Hello().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton improve_button;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JLabel message;
+ // End of variables declaration//GEN-END:variables
+
+}
View
4 examples/HelloMonkeybars/src/application_controller.rb
@@ -0,0 +1,4 @@
+class ApplicationController < Monkeybars::Controller
+ # Add content here that you want to be available to all the controllers
+ # in your application
+end
View
3  examples/HelloMonkeybars/src/application_view.rb
@@ -0,0 +1,3 @@
+class ApplicationView < Monkeybars::View
+ # Add content here that you want to be available to all the views in your application
+end
View
10 examples/HelloMonkeybars/src/greeter/greeter_controller.rb
@@ -0,0 +1,10 @@
+class GreeterController < ApplicationController
+ set_model 'GreeterModel'
+ set_view 'GreeterView'
+ set_close_action :exit
+
+ def improve_button_action_performed
+ model.message = "<html>But Swing with Monkeybars<br>is awesome!</html>"
+ update_view
+ end
+end
View
7 examples/HelloMonkeybars/src/greeter/greeter_model.rb
@@ -0,0 +1,7 @@
+class GreeterModel
+ attr_accessor :message
+
+ def initialize
+ @message = "Swing is ok..."
+ end
+end
View
5 examples/HelloMonkeybars/src/greeter/greeter_view.rb
@@ -0,0 +1,5 @@
+class GreeterView < ApplicationView
+ set_java_class 'Hello'
+
+ map :view => "message.text", :model => :message
+end
View
53 examples/HelloMonkeybars/src/main.rb
@@ -0,0 +1,53 @@
+#===============================================================================
+# Much of the platform specific code should be called before Swing is touched.
+# The useScreenMenuBar is an example of this.
+require 'rbconfig'
+require 'java'
+
+#===============================================================================
+# Platform specific operations, feel free to remove or override any of these
+# that don't work for your platform/application
+
+case Config::CONFIG["host_os"]
+when /darwin/i # OSX specific code
+ java.lang.System.set_property("apple.laf.useScreenMenuBar", "true")
+when /^win|mswin/i # Windows specific code
+when /linux/i # Linux specific code
+end
+
+# End of platform specific code
+#===============================================================================
+$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
+require 'manifest'
+
+# Set up global error handling so that it is consistantly logged or outputed
+# You will probably want to replace the puts with your application's logger
+def show_error_dialog_and_exit(exception, thread=nil)
+ puts "Error in application"
+ puts "#{exception.class} - #{exception}"
+ if exception.kind_of? Exception
+ puts exception.backtrace.join("\n")
+ else
+ # Workaround for JRuby issue #2673, getStackTrace returning an empty array
+ output_stream = java.io.ByteArrayOutputStream.new
+ exception.printStackTrace(java.io.PrintStream.new(output_stream))
+ puts output_stream.to_string
+ end
+
+ # Your error handling code goes here
+
+ # Show error dialog informing the user that there was an error
+ title = "Application Error"
+ message = "The application has encountered an error and must shut down."
+
+ javax.swing.JOptionPane.show_message_dialog(nil, message, title, javax.swing.JOptionPane::DEFAULT_OPTION)
+ java.lang.System.exit(0)
+end
+GlobalErrorHandler.on_error {|exception, thread| show_error_dialog_and_exit(exception, thread) }
+
+begin
+require 'greeter_controller'
+GreeterController.instance.open
+rescue => e
+ show_error_dialog_and_exit(e)
+end
View
61 examples/HelloMonkeybars/src/manifest.rb
@@ -0,0 +1,61 @@
+Dir.glob(File.expand_path(File.dirname(__FILE__) + "/**/*").gsub('%20', ' ')).each do |directory|
+ # File.directory? is broken in current JRuby for dirs inside jars
+ # http://jira.codehaus.org/browse/JRUBY-2289
+ $LOAD_PATH << directory unless directory =~ /\.\w+$/
+end
+# Some JRuby $LOAD_PATH path bugs to check if you're having trouble:
+# http://jira.codehaus.org/browse/JRUBY-2518 - Dir.glob and Dir[] doesn't work
+# for starting in a dir in a jar
+# (such as Active-Record migrations)
+# http://jira.codehaus.org/browse/JRUBY-3247 - Compiled Ruby classes produce
+# word substitutes for characters
+# like - and . (to minus and dot).
+# This is problematic with gems
+# like ActiveSupport and Prawn
+
+#===============================================================================
+# Monkeybars requires, this pulls in the requisite libraries needed for
+# Monkeybars to operate.
+
+require 'resolver'
+
+
+def monkeybars_jar path
+ Dir.glob(path).select { |f| f =~ /(monkeybars-)(.+).jar$/}.first
+end
+
+case Monkeybars::Resolver.run_location
+when Monkeybars::Resolver::IN_FILE_SYSTEM
+ here = File.expand_path File.dirname(__FILE__)
+ add_to_classpath monkeybars_jar( here + '/../lib/java/*.jar' )
+end
+
+require 'monkeybars'
+require 'application_controller'
+require 'application_view'
+
+# End of Monkeybars requires
+#===============================================================================
+#
+# Add your own application-wide libraries below. To include jars, append to
+# $CLASSPATH, or use add_to_classpath, for example:
+#
+# $CLASSPATH << File.expand_path(File.dirname(__FILE__) + "/../lib/java/swing-layout-1.0.3.jar")
+#
+# is equivalent to
+#
+# add_to_classpath "../lib/java/swing-layout-1.0.3.jar"
+#
+# There is also a helper for adding to your load path and avoiding issues with file: being
+# appended to the load path (useful for JRuby libs that need your jar directory on
+# the load path).
+#
+# add_to_load_path "../lib/java"
+#
+
+case Monkeybars::Resolver.run_location
+when Monkeybars::Resolver::IN_FILE_SYSTEM
+ # Files to be added only when running from the file system go here
+when Monkeybars::Resolver::IN_JAR_FILE
+ # Files to be added only when run from inside a jar file
+end
View
67 examples/HelloMonkeybars/src/org/rubyforge/rawr/Main.java
@@ -0,0 +1,67 @@
+package org.rubyforge.rawr;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
+
+import java.util.ArrayList;
+import org.jruby.Ruby;
+import org.jruby.RubyInstanceConfig;
+import org.jruby.javasupport.JavaEmbedUtils;
+
+public class Main
+{
+ public static void main(String[] args) throws Exception
+ {
+ RubyInstanceConfig config = new RubyInstanceConfig();
+ config.setArgv(args);
+ Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
+ String mainRubyFile = "main";
+
+ ArrayList<String> config_data = new ArrayList<String>();
+ try{
+ java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
+ if (ins == null ) {
+ System.err.println("Did not find configuration file 'run_configuration', using defaults.");
+ } else {
+ config_data = getConfigFileContents(ins);
+ }
+ }
+ catch(IOException ioe)
+ {
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
+ }
+ catch(java.lang.NullPointerException npe)
+ {
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
+ }
+
+ for(String line : config_data) {
+ String[] parts = line.split(":");
+ if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
+ mainRubyFile = parts[1].replaceAll(" ", "");
+ }
+ }
+
+ runtime.evalScriptlet("require '" + mainRubyFile + "'");
+ }
+
+ public static URL getResource(String path) {
+ return Main.class.getClassLoader().getResource(path);
+ }
+
+ private static ArrayList<String> getConfigFileContents(InputStream input) throws IOException, java.lang.NullPointerException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(input));
+ String line;
+ ArrayList<String> contents = new ArrayList<String>();
+
+ while ((line = reader.readLine()) != null) {
+ contents.add(line);
+ }
+ reader.close();
+ return(contents);
+ }
+}
View
33 examples/HelloMonkeybars/src/resolver.rb
@@ -0,0 +1,33 @@
+module Monkeybars
+ class Resolver
+ IN_FILE_SYSTEM = :in_file_system
+ IN_JAR_FILE = :in_jar_file
+
+ # Returns a const value indicating if the currently executing code is being run from the file system or from within a jar file.
+ def self.run_location
+ if File.expand_path(__FILE__) =~ /\.jar\!/
+ IN_JAR_FILE
+ else
+ IN_FILE_SYSTEM
+ end
+ end
+ end
+end
+
+class Object
+ def add_to_classpath(path)
+ $CLASSPATH << get_expanded_path(path)
+ end
+
+ def add_to_load_path(path)
+ $LOAD_PATH << get_expanded_path(path)
+ end
+
+ private
+ def get_expanded_path(path)
+ resolved_path = File.expand_path(File.dirname(__FILE__) + "/" + path.gsub("\\", "/"))
+ resolved_path.gsub!("file:", "") unless resolved_path.index(".jar!")
+ resolved_path.gsub!("%20", ' ')
+ resolved_path
+ end
+end
View
89 examples/HelloMonkeybars/tasks/monkeybars.rake
@@ -0,0 +1,89 @@
+require 'fileutils'
+
+desc "ALL, CONTROLLER, VIEW, MODEL are valid options."
+task 'generate'
+rule(/^generate/) do |t|
+ ARGV[1..-1].each do |generator_command|
+ command, argument = generator_command.split("=")
+ case command
+ when "ALL"
+ generate_tuple(argument)
+ when "VIEW"
+ generate_view(argument)
+ when "CONTROLLER"
+ generate_controller(argument)
+ when "MODEL"
+ generate_model(argument)
+ else
+ $stdout << "Unknown generate target #{argument}"
+ end
+ end
+end
+
+def generate_tuple(path)
+ pwd = FileUtils.pwd
+ generate_controller(path)
+ FileUtils.cd(pwd)
+ generate_model(path)
+ FileUtils.cd(pwd)
+ generate_view(path)
+end
+
+def generate_controller(path)
+ name = setup_directory(path)
+ file_name = "#{name}_controller.rb"
+ name = camelize(name)
+ $stdout << "Generating controller #{name}Controller in file #{file_name}\n"
+ File.open(file_name, "w") do |controller_file|
+ controller_file << <<-ENDL
+class #{name}Controller < ApplicationController
+ set_model '#{name}Model'
+ set_view '#{name}View'
+ set_close_action :exit
+end
+ ENDL
+ end
+end
+
+def generate_model(path)
+ name = setup_directory(path)
+ file_name = "#{name}_model.rb"
+ name = camelize(name)
+ $stdout << "Generating model #{name}Model in file #{file_name}\n"
+ File.open(file_name, "w") do |model_file|
+ model_file << <<-ENDL
+class #{name}Model
+
+end
+ ENDL
+ end
+end
+
+def generate_view(path)
+ name = setup_directory(path)
+ file_name = "#{name}_view.rb"
+ name = camelize(name)
+ $stdout << "Generating view #{name}View in file #{file_name}\n"
+ File.open(file_name, "w") do |view_file|
+ view_file << <<-ENDL
+class #{name}View < ApplicationView
+ set_java_class ''
+end
+ ENDL
+ end
+end
+
+def setup_directory(path)
+ FileUtils.mkdir_p path.gsub("\\", "/")
+ FileUtils.cd(path)
+ path.split("/").last
+end
+
+def camelize(name, first_letter_in_uppercase = true)
+ name = name.to_s
+ if first_letter_in_uppercase
+ name.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
+ else
+ name[0..0] + camelize(name[1..-1])
+ end
+end
View
4 examples/Nested-Simple/Rakefile
@@ -0,0 +1,4 @@
+require 'rawr'
+Dir.glob("tasks/**/*.rake").each do |rake_file|
+ load File.expand_path(File.dirname(__FILE__) + "/" + rake_file)
+end
View
92 examples/Nested-Simple/build_configuration.rb
@@ -0,0 +1,92 @@
+configuration do |c|
+ # The name for your resulting application file (e.g., if the project_name is 'foo' then you'll get foo.jar, foo.exe, etc.)
+ # default value: "Nested-Simple"
+ #
+ #c.project_name = "Nested-Simple"
+
+ # Undocumented option 'output_dir'
+ # default value: "package"
+ #
+ #c.output_dir = "package"
+
+ # The main ruby file to invoke, minus the .rb extension
+ # default value: "main"
+ #
+ #c.main_ruby_file = "main"
+
+ # The fully-qualified name of the main Java file used to initiate the application.
+ # default value: "org.rubyforge.rawr.Main"
+ #
+ #c.main_java_file = "org.rubyforge.rawr.Main"
+
+ # A list of directories where source files reside
+ # default value: ["src"]
+ #
+ #c.source_dirs = ["src"]
+
+ # A list of regexps of files to exclude
+ # default value: []
+ #
+ #c.source_exclude_filter = []
+
+ # Whether Ruby source files should be compiled into .class files
+ # default value: true
+ #
+ #c.compile_ruby_files = true
+
+ # A list of individual Java library files to include.
+ # default value: []
+ #
+ #c.java_lib_files = []
+
+ # A list of directories for rawr to include . All files in the given directories get bundled up.
+ # default value: ["lib/java"]
+ #
+ #c.java_lib_dirs = ["lib/java"]
+
+ # Undocumented option 'files_to_copy'
+ # default value: []
+ #
+ #c.files_to_copy = []
+
+ # Undocumented option 'target_jvm_version'
+ # default value: 1.6
+ #
+ #c.target_jvm_version = 1.6
+
+ # Undocumented option 'jvm_arguments'
+ # default value: ""
+ #
+ #c.jvm_arguments = ""
+
+ # Undocumented option 'java_library_path'
+ # default value: ""
+ #
+ #c.java_library_path = ""
+
+ # Undocumented option 'extra_user_jars'
+ # default value: {}
+ #
+ #c.extra_user_jars[:data] = { :directory => 'data/images/png',
+ # :location_in_jar => 'images',
+ # :exclude => /*.bak$/ }
+
+ # Undocumented option 'mac_do_not_generate_plist'
+ # default value: nil
+ #
+ #c.mac_do_not_generate_plist = nil
+
+ # Undocumented option 'mac_icon_path'
+ # default value: nil
+ #
+ #c.mac_icon_path = nil
+
+ # Undocumented option 'windows_icon_path'
+ # default value: nil
+ #
+ #c.windows_icon_path = nil
+
+ c.mac_icon_path = File.expand_path('icons/monkeybars.icns')
+ c.windows_icon_path = File.expand_path('icons/monkeybars.ico')
+end
+
View
BIN  examples/Nested-Simple/icons/monkeybars.icns
Binary file not shown
View
BIN  examples/Nested-Simple/icons/monkeybars.ico
Binary file not shown
View
1  examples/Nested-Simple/lib/java/README.txt
@@ -0,0 +1 @@
+Place your jars here.
View
BIN  examples/Nested-Simple/lib/java/swing-layout-1.0.3.jar
Binary file not shown
View
1  examples/Nested-Simple/lib/ruby/README.txt
@@ -0,0 +1 @@
+3rd party Ruby libs and unpacked gems go here.
View
4 examples/Nested-Simple/src/application_controller.rb
@@ -0,0 +1,4 @@
+class ApplicationController < Monkeybars::Controller
+ # Add content here that you want to be available to all the controllers
+ # in your application
+end
View
3  examples/Nested-Simple/src/application_view.rb
@@ -0,0 +1,3 @@
+class ApplicationView < Monkeybars::View
+ # Add content here that you want to be available to all the views in your application
+end
View
82 examples/Nested-Simple/src/list/ListFrame.form
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ <Property name="title" type="java.lang.String" value="Worst Movies Ever"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jScrollPane1" alignment="0" pref="360" max="32767" attributes="0"/>
+ <Component id="search_landing_panel" alignment="1" min="-2" max="-2" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="search_landing_panel" min="-2" pref="38" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jScrollPane1" pref="161" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JList" name="items_list">
+ <Properties>
+ <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
+ <StringArray count="9">
+ <StringItem index="0" value="Manos: The Hands of Fate"/>
+ <StringItem index="1" value="Plan 9 from Outer Space"/>
+ <StringItem index="2" value="Anus Magillicutty"/>
+ <StringItem index="3" value="Monster A Go Go"/>
+ <StringItem index="4" value="Ballistic: Ecks vs. Sever"/>
+ <StringItem index="5" value="Santa Claus Conquers the Martians"/>
+ <StringItem index="6" value="From Justin to Kelly"/>
+ <StringItem index="7" value="An Alan Smithee Film: Burn Hollywood Burn"/>
+ <StringItem index="8" value="Batman &amp; Robin"/>
+ </StringArray>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="search_landing_panel">
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
+ <SubComponents>
+ <Component class="search.SearchPanel" name="searchPanel1">
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
View
77 examples/Nested-Simple/src/list/ListFrame.java
@@ -0,0 +1,77 @@
+/*
+ * ListFrame.java
+ *
+ * Created on June 15, 2008, 10:50 PM
+ */
+
+package list;
+
+/**
+ *
+ * @author logan
+ */
+public class ListFrame extends javax.swing.JFrame {
+
+ /** Creates new form ListFrame */
+ public ListFrame() {
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jScrollPane1 = new javax.swing.JScrollPane();
+ items_list = new javax.swing.JList();
+ search_landing_panel = new javax.swing.JPanel();
+ searchPanel1 = new search.SearchPanel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("Worst Movies Ever");
+
+ items_list.setModel(new javax.swing.AbstractListModel() {
+ String[] strings = { "Manos: The Hands of Fate", "Plan 9 from Outer Space", "Anus Magillicutty", "Monster A Go Go", "Ballistic: Ecks vs. Sever", "Santa Claus Conquers the Martians", "From Justin to Kelly", "An Alan Smithee Film: Burn Hollywood Burn", "Batman & Robin" };
+ public int getSize() { return strings.length; }
+ public Object getElementAt(int i) { return strings[i]; }
+ });
+ jScrollPane1.setViewportView(items_list);
+
+ search_landing_panel.setLayout(new javax.swing.BoxLayout(search_landing_panel, javax.swing.BoxLayout.LINE_AXIS));
+ search_landing_panel.add(searchPanel1);
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
+ .add(search_landing_panel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(search_landing_panel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JList items_list;
+ private javax.swing.JScrollPane jScrollPane1;
+ private search.SearchPanel searchPanel1;
+ private javax.swing.JPanel search_landing_panel;
+ // End of variables declaration//GEN-END:variables
+
+}
View
33 examples/Nested-Simple/src/list/list_controller.rb
@@ -0,0 +1,33 @@
+require 'search_controller'
+
+class ListController < ApplicationController
+ set_model 'ListModel'
+ set_view 'ListView'
+ set_close_action :exit
+
+ LIST = ["Manos: The Hands of Fate",
+ "Plan 9 from Outer Space",
+ "Anus Magillicutty",
+ "Monster A Go Go",
+ "Ballistic: Ecks vs. Sever",
+ "Santa Clause Conquers the Martians",
+ "From Justin to Kelly",
+ "An Alan Smithee Film: Burn Hollywood Burn",
+ "Batman & Robin"].freeze
+
+ def load
+ search_controller = SearchController.instance
+ search_controller.open
+ add_nested_controller(:search, search_controller)
+
+ search_controller.when_search_changed do |filter|
+ filter_list(filter)
+ end
+ end
+
+ def filter_list(filter)
+ filtered_list = LIST.dup.delete_if {|element| element !~ Regexp.new(filter)}
+ transfer[:list] = filtered_list
+ update_view
+ end
+end
View
3  examples/Nested-Simple/src/list/list_model.rb
@@ -0,0 +1,3 @@
+class ListModel
+
+end
View
15 examples/Nested-Simple/src/list/list_view.rb
@@ -0,0 +1,15 @@
+class ListView < ApplicationView
+ set_java_class 'list.ListFrame'
+
+ map :view => 'items_list.model', :transfer => :list, :using => [:to_list_model, nil]
+
+ nest :sub_view => :search, :view => :search_landing_panel
+
+ def load
+ search_landing_panel.remove_all
+ end
+
+ def to_list_model(list)
+ Java::javax.swing::DefaultComboBoxModel.new(list.to_java(:String))
+ end
+end
View
55 examples/Nested-Simple/src/main.rb
@@ -0,0 +1,55 @@
+#===============================================================================
+# Much of the platform specific code should be called before Swing is touched.
+# The useScreenMenuBar is an example of this.
+require 'rbconfig'
+require 'java'
+
+#===============================================================================
+# Platform specific operations, feel free to remove or override any of these
+# that don't work for your platform/application
+
+case Config::CONFIG["host_os"]
+when /darwin/i # OSX specific code
+ java.lang.System.set_property("apple.laf.useScreenMenuBar", "true")
+when /^win|mswin/i # Windows specific code
+when /linux/i # Linux specific code
+end
+
+# End of platform specific code
+#===============================================================================
+$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
+require 'manifest'
+
+# Set up global error handling so that it is consistantly logged or outputed
+# You will probably want to replace the puts with your application's logger
+def show_error_dialog_and_exit(exception, thread=nil)
+ puts "Error in application"
+ puts "#{exception.class} - #{exception}"
+ if exception.kind_of? Exception
+ puts exception.backtrace.join("\n")
+ else
+ # Workaround for JRuby issue #2673, getStackTrace returning an empty array
+ output_stream = java.io.ByteArrayOutputStream.new
+ exception.printStackTrace(java.io.PrintStream.new(output_stream))
+ puts output_stream.to_string
+ end
+
+ # Your error handling code goes here
+
+ # Show error dialog informing the user that there was an error
+ title = "Application Error"
+ message = "The application has encountered an error and must shut down."
+
+ javax.swing.JOptionPane.show_message_dialog(nil, message, title, javax.swing.JOptionPane::DEFAULT_OPTION)
+ java.lang.System.exit(0)
+end
+GlobalErrorHandler.on_error {|exception, thread| show_error_dialog_and_exit(exception, thread) }
+
+begin
+ # Your application code goes here
+
+require 'list_controller'
+ListController.instance.open
+rescue => e
+ show_error_dialog_and_exit(e)
+end
View
65 examples/Nested-Simple/src/manifest.rb
@@ -0,0 +1,65 @@
+Dir.glob(File.expand_path(File.dirname(__FILE__) + "/**/*").gsub('%20', ' ')).each do |directory|
+ # File.directory? is broken in current JRuby for dirs inside jars
+ # http://jira.codehaus.org/browse/JRUBY-2289
+ $LOAD_PATH << directory unless directory =~ /\.\w+$/
+end
+# Some JRuby $LOAD_PATH path bugs to check if you're having trouble:
+# http://jira.codehaus.org/browse/JRUBY-2518 - Dir.glob and Dir[] doesn't work
+# for starting in a dir in a jar
+# (such as Active-Record migrations)
+# http://jira.codehaus.org/browse/JRUBY-3247 - Compiled Ruby classes produce
+# word substitutes for characters
+# like - and . (to minus and dot).
+# This is problematic with gems
+# like ActiveSupport and Prawn
+
+#===============================================================================
+# Monkeybars requires, this pulls in the requisite libraries needed for
+# Monkeybars to operate.
+
+require 'resolver'
+
+
+def monkeybars_jar path
+ Dir.glob(path).select { |f| f =~ /(monkeybars-)(.+).jar$/}.first
+end
+
+case Monkeybars::Resolver.run_location
+when Monkeybars::Resolver::IN_FILE_SYSTEM
+ here = File.expand_path File.dirname(__FILE__)
+ add_to_classpath monkeybars_jar( here + '/../lib/java/*.jar' )
+end
+
+require 'monkeybars'
+require 'application_controller'
+require 'application_view'
+
+# End of Monkeybars requires
+#===============================================================================
+#
+# Add your own application-wide libraries below. To include jars, append to
+# $CLASSPATH, or use add_to_classpath, for example:
+#
+# $CLASSPATH << File.expand_path(File.dirname(__FILE__) + "/../lib/java/swing-layout-1.0.3.jar")
+#
+# is equivalent to
+#
+# add_to_classpath "../lib/java/swing-layout-1.0.3.jar"
+#
+# There is also a helper for adding to your load path and avoiding issues with file: being
+# appended to the load path (useful for JRuby libs that need your jar directory on
+# the load path).
+#
+# add_to_load_path "../lib/java"
+#
+
+case Monkeybars::Resolver.run_location
+when Monkeybars::Resolver::IN_FILE_SYSTEM
+ # Files to be added only when running from the file system go here
+ add_to_classpath "../lib/java/jruby-complete.jar"
+ add_to_classpath "../lib/java/swing-layout-1.0.3.jar"
+ add_to_classpath monkeybars_jar( here + '/../lib/java/*.jar' )
+ add_to_classpath "../build/classes"
+when Monkeybars::Resolver::IN_JAR_FILE
+ # Files to be added only when run from inside a jar file
+end
View
67 examples/Nested-Simple/src/org/rubyforge/rawr/Main.java
@@ -0,0 +1,67 @@
+package org.rubyforge.rawr;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
+
+import java.util.ArrayList;
+import org.jruby.Ruby;
+import org.jruby.RubyInstanceConfig;
+import org.jruby.javasupport.JavaEmbedUtils;
+
+public class Main
+{
+ public static void main(String[] args) throws Exception
+ {
+ RubyInstanceConfig config = new RubyInstanceConfig();
+ config.setArgv(args);
+ Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
+ String mainRubyFile = "main";
+
+ ArrayList<String> config_data = new ArrayList<String>();
+ try{
+ java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
+ if (ins == null ) {
+ System.err.println("Did not find configuration file 'run_configuration', using defaults.");
+ } else {
+ config_data = getConfigFileContents(ins);
+ }
+ }
+ catch(IOException ioe)
+ {
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
+ }
+ catch(java.lang.NullPointerException npe)
+ {
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
+ }
+
+ for(String line : config_data) {
+ String[] parts = line.split(":");
+ if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
+ mainRubyFile = parts[1].replaceAll(" ", "");
+ }
+ }
+
+ runtime.evalScriptlet("require '" + mainRubyFile + "'");
+ }
+
+ public static URL getResource(String path) {
+ return Main.class.getClassLoader().getResource(path);
+ }
+
+ private static ArrayList<String> getConfigFileContents(InputStream input) throws IOException, java.lang.NullPointerException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(input));
+ String line;
+ ArrayList<String> contents = new ArrayList<String>();
+
+ while ((line = reader.readLine()) != null) {
+ contents.add(line);
+ }
+ reader.close();
+ return(contents);
+ }
+}
View
33 examples/Nested-Simple/src/resolver.rb
@@ -0,0 +1,33 @@
+module Monkeybars
+ class Resolver
+ IN_FILE_SYSTEM = :in_file_system
+ IN_JAR_FILE = :in_jar_file
+
+ # Returns a const value indicating if the currently executing code is being run from the file system or from within a jar file.
+ def self.run_location
+ if File.expand_path(__FILE__) =~ /\.jar\!/
+ IN_JAR_FILE
+ else
+ IN_FILE_SYSTEM
+ end
+ end
+ end
+end
+
+class Object
+ def add_to_classpath(path)
+ $CLASSPATH << get_expanded_path(path)
+ end
+
+ def add_to_load_path(path)
+ $LOAD_PATH << get_expanded_path(path)
+ end
+
+ private
+ def get_expanded_path(path)
+ resolved_path = File.expand_path(File.dirname(__FILE__) + "/" + path.gsub("\\", "/"))
+ resolved_path.gsub!("file:", "") unless resolved_path.index(".jar!")
+ resolved_path.gsub!("%20", ' ')
+ resolved_path
+ end
+end
View
43 examples/Nested-Simple/src/search/SearchPanel.form
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="search_text_field" pref="132" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="103" alignment="0" groupAlignment="3" attributes="0">
+ <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="search_text_field" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Search"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="search_text_field">
+ </Component>
+ </SubComponents>
+</Form>
View
57 examples/Nested-Simple/src/search/SearchPanel.java
@@ -0,0 +1,57 @@
+/*
+ * SearchPanel.java
+ *
+ * Created on June 15, 2008, 10:55 PM
+ */
+
+package search;
+
+/**
+ *
+ * @author logan
+ */
+public class SearchPanel extends javax.swing.JPanel {
+
+ /** Creates new form SearchPanel */
+ public SearchPanel() {
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ search_text_field = new javax.swing.JTextField();
+
+ jLabel1.setText("Search");
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(search_text_field, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel1)
+ .add(search_text_field, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JTextField search_text_field;
+ // End of variables declaration//GEN-END:variables
+
+}
View
20 examples/Nested-Simple/src/search/search_controller.rb
@@ -0,0 +1,20 @@
+class SearchController < ApplicationController
+ set_model 'SearchModel'
+ set_view 'SearchView'
+ set_close_action :close
+
+ add_listener :type => :document, :components => {"search_text_field.document" => "search_text_field"}
+
+ def when_search_changed(&block)
+ @search_changed_callback = block
+ end
+
+ def search_text_field_insert_update(document_event)
+ model.search_text = document_event.document.get_text(0, document_event.document.length)
+ @search_changed_callback.call model.search_text unless @search_changed_callback.nil?
+ end
+
+ def search_text_field_remove_update(document_event)
+ search_text_field_insert_update(document_event)
+ end
+end
View
7 examples/Nested-Simple/src/search/search_model.rb
@@ -0,0 +1,7 @@
+class SearchModel
+ attr_accessor :search_text
+
+ def initialzie
+ self.search_text = ""
+ end
+end
View
3  examples/Nested-Simple/src/search/search_view.rb
@@ -0,0 +1,3 @@
+class SearchView < ApplicationView
+ set_java_class 'search.SearchPanel'
+end
View
89 examples/Nested-Simple/tasks/monkeybars.rake
@@ -0,0 +1,89 @@
+require 'fileutils'
+
+desc "ALL, CONTROLLER, VIEW, MODEL are valid options."
+task 'generate'
+rule(/^generate/) do |t|
+ ARGV[1..-1].each do |generator_command|
+ command, argument = generator_command.split("=")
+ case command
+ when "ALL"
+ generate_tuple(argument)
+ when "VIEW"
+ generate_view(argument)
+ when "CONTROLLER"
+ generate_controller(argument)
+ when "MODEL"
+ generate_model(argument)
+ else
+ $stdout << "Unknown generate target #{argument}"
+ end
+ end
+end
+
+def generate_tuple(path)
+ pwd = FileUtils.pwd
+ generate_controller(path)
+ FileUtils.cd(pwd)
+ generate_model(path)
+ FileUtils.cd(pwd)
+ generate_view(path)
+end
+
+def generate_controller(path)
+ name = setup_directory(path)
+ file_name = "#{name}_controller.rb"
+ name = camelize(name)
+ $stdout << "Generating controller #{name}Controller in file #{file_name}\n"
+ File.open(file_name, "w") do |controller_file|
+ controller_file << <<-ENDL
+class #{name}Controller < ApplicationController
+ set_model '#{name}Model'
+ set_view '#{name}View'
+ set_close_action :exit
+end
+ ENDL
+ end
+end
+
+def generate_model(path)
+ name = setup_directory(path)
+ file_name = "#{name}_model.rb"
+ name = camelize(name)
+ $stdout << "Generating model #{name}Model in file #{file_name}\n"
+ File.open(file_name, "w") do |model_file|
+ model_file << <<-ENDL
+class #{name}Model
+
+end
+ ENDL
+ end
+end
+
+def generate_view(path)
+ name = setup_directory(path)
+ file_name = "#{name}_view.rb"
+ name = camelize(name)
+ $stdout << "Generating view #{name}View in file #{file_name}\n"
+ File.open(file_name, "w") do |view_file|
+ view_file << <<-ENDL
+class #{name}View < ApplicationView
+ set_java_class ''
+end
+ ENDL
+ end
+end
+
+def setup_directory(path)
+ FileUtils.mkdir_p path.gsub("\\", "/")
+ FileUtils.cd(path)
+ path.split("/").last
+end
+
+def camelize(name, first_letter_in_uppercase = true)
+ name = name.to_s
+ if first_letter_in_uppercase
+ name.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
+ else
+ name[0..0] + camelize(name[1..-1])
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.