require ENV['TM_BUNDLE_SUPPORT'] + '/lib/connect.rb' #Retrieve a p4 object from connect.rb then connect to the server conn = Connect.new p4 = conn.connect p "in" if p4 change_no = '' output = '' #Retrieve the changelists available for a submit pending = p4.run_changes('-c', p4.client, '-u', p4.user, '-s', 'pending') items = [] pending.each do |i| items << i['change'] end change = conn.get_changelist_choice("Submit", items.include?('default') ? ['default'] : []) #Submit nib jobs_arr = ['a', 'b', 'c'] files_arr = ['x', 'y', 'z'] string_dict = {} string_dict['description'] = "A description" params = {} params['jobs'] = ['a','b','c'] params['files'] = ['x','y','z'] params['description'] = "A description" output = [] puts "here" TextMate::UI.dialog(:nib => ENV['TM_BUNDLE_SUPPORT'] + '/nibs/submit_test.nib', :parameters => params, :center => true) { |window| return_hash = window.wait_for_input puts return_hash.keys } # Request an item from a list of items def request_item(options = Hash.new,&block) items = options[:items] || [] case items.size when 0 then block_given? ? raise(SystemExit) : nil when 1 then block_given? ? yield(items[0]) : items[0] else params = default_buttons(options) params["title"] = options[:title] || "Select item:" params["prompt"] = options[:prompt] || "" params["string"] = options[:default] || "" params["items"] = items return_plist = %x{#{TM_DIALOG} -cmp #{e_sh params.to_plist} #{e_sh(ENV['TM_SUPPORT_PATH'] + "/nibs/RequestItem")}} return_hash = OSX::PropertyList::load(return_plist) # return string is in hash->result->returnArgument. # If cancel button was clicked, hash->result is nil. return_value = return_hash['result'] return_value = return_value['returnArgument'] if not return_value.nil? return_value = return_value.first if return_value.is_a? Array if return_value == nil then block_given? ? raise(SystemExit) : nil else block_given? ? yield(return_value) : return_value end end end else p "failed to connect" end __END__ begin if change[0] == "pending" change_no = change[1] output = p4.run_submit('-c', change_no) elsif change[0] == "default" change_no = "default" output = p4.run_submit(path_out) else #Something funny has happened :( output = "Oh dear, oh dear, oh dear; please e-mail bbates@perforce.co.uk" end rescue Exception => msg p4.disconnect abort(msg) end p4.disconnect abort(output.to_s) else p4.disconnect abort("Failed to connect, please check your settings") end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 7920 | Brett Bates |
Rename submit.rb to submit_gui.rb to work on later - too many issues with �_dialog2 at the moment |
||
//guest/brettb/Perforce.tmbundle/Support/lib/submit.rb | |||||
#3 | 7919 | Brett Bates | Further attempts to get the nib to return data... | ||
#2 | 7916 | Brett Bates | Updating | ||
#1 | 7914 | Brett Bates | Correctly adding Perforce.tmbundle |