Source

lqpl / GUI / src / manifest.rb

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


#puts "set loadpath #{$LOAD_PATH}"
# 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__)
    npath = here + '/../lib/java/*.jar'
#    puts npath
    mbj =   monkeybars_jar( here + '/../lib/java/*.jar' )
#    puts "resulting mbj=#{mbj}"
    if !mbj || mbj == ''
      mbj =  monkeybars_jar( here + '/../../../lib/java/*.jar' )
#      puts "or is #{mbj}"
    end
    add_to_classpath mbj
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


%w{JOptionPane JFileChooser filechooser.FileNameExtensionFilter JTextArea JScrollPane}.each do |cfile|
  java_import "javax.swing."+cfile
end

java_import com.drogar.lqpl.qstack.Painter

java_import java.lang.System

java_import java.awt.Point

%w{point jfile_chooser array}.each do |rfile|
  require 'utility/monkey/'+rfile
end


%w{translate_line_ends xml_decode drawing}.each do |f|
  require "utility/"+f
end

%w{abstract zero value abstract_list qubit data classical}.each do |rf|
  require "panels/parsers/"+rf+"_pattern_parser"
end

require 'painting/canvas_size'
require 'application_model'

require 'xml_based_model'

%w{server_process_not_found invalid_input}.each do |f|
  require "exceptions/"+f
end


%w{lqpl_emulator_server_connection compiler_server_connection}.each do |f|
  require "communications/"+f
end
%w{abstract classical data qubit value zero}.each do |rf|
  require "panels/quantum_stack/descriptor/#{rf}_descriptor_model"
  require "panels/quantum_stack/descriptor/#{rf}_descriptor_painter"
end

require 'panels/quantum_stack/descriptor/descriptor_painter_factory'
require 'panels/quantum_stack/quantum_stack_painter'

{ ""=>%w{lqpl}, 
  "panels/" => %w{quantum_stack classical_stack dump executable_code stack_translation},
  "dialogs/" =>%w{simulate_results about}}.each do |k,v|
    v.each do |f|   
      require k+f+"/"+f+"_view" 
      require k+f+"/"+f+"_model" 
      require k+f+"/"+f+"_controller" 
    end
end

require "exit_handler"