Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
apex execute anonymous functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Ferraro committed Aug 26, 2012
1 parent 5cfb8a7 commit 5291253
Show file tree
Hide file tree
Showing 12 changed files with 473 additions and 20 deletions.
8 changes: 6 additions & 2 deletions Default.sublime-commands
Expand Up @@ -20,8 +20,12 @@
"command": "compile_project" "command": "compile_project"
}, },
{ {
"caption": "Run Apex Tests", "caption": "MavensMate: Run Apex Tests",
"command": "run_apex_unit_tests" "command": "run_apex_unit_tests"
},
{
"caption": "MavensMate: Execute Apex",
"command": "execute_anonymous"
}, },
{ {
"caption": "MavensMate: New Apex Class", "caption": "MavensMate: New Apex Class",
Expand Down
4 changes: 4 additions & 0 deletions Main.sublime-menu
Expand Up @@ -59,6 +59,10 @@
"caption": "Run Apex Tests", "caption": "Run Apex Tests",
"command": "run_apex_unit_tests" "command": "run_apex_unit_tests"
}, },
{
"caption": "Execute Apex",
"command": "execute_anonymous"
},
{ {
"id": "compile_active", "id": "compile_active",
"caption": "Compile Active File", "caption": "Compile Active File",
Expand Down
7 changes: 7 additions & 0 deletions commands/execute_anonymous.rb
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby -W0
require File.dirname(File.dirname(__FILE__)) + "/constants.rb"
include Constants
require SUPPORT + "/environment.rb"
require CONTROLLERS_ROOT + "/execute_controller.rb"
ENV["MM_CURRENT_PROJECT_DIRECTORY"] = ARGV[0]
dispatch :controller => "execute", :action => "index"
26 changes: 23 additions & 3 deletions mavensmate.py
Expand Up @@ -116,6 +116,12 @@ def run (self, dirs):
thread.start() thread.start()
handle_threads(threads, printer, handle_result, 0) handle_threads(threads, printer, handle_result, 0)


class ExecuteAnonymousCommand(sublime_plugin.ApplicationCommand):
def run(command):
start_local_server()
temp_file_name = generate_ui("execute_anonymous", mm_project_directory())
launch_mavens_mate_window(temp_file_name)

#displays edit project dialog #displays edit project dialog
class EditProjectCommand(sublime_plugin.ApplicationCommand): class EditProjectCommand(sublime_plugin.ApplicationCommand):
def run(command): def run(command):
Expand Down Expand Up @@ -183,7 +189,7 @@ def run(self, files):
if sublime.ok_cancel_dialog("Are you sure you want to delete the selected files from Salesforce?", "Delete"): if sublime.ok_cancel_dialog("Are you sure you want to delete the selected files from Salesforce?", "Delete"):
printer = PanelPrinter.get(self.window.id()) printer = PanelPrinter.get(self.window.id())
printer.show() printer.show()
printer.write('Deleting Selected Metadata\n') printer.write('\nDeleting Selected Metadata\n')
file_string = ','.join(files) file_string = ','.join(files)
temp = tempfile.NamedTemporaryFile(delete=False, prefix="mm") temp = tempfile.NamedTemporaryFile(delete=False, prefix="mm")
try: try:
Expand Down Expand Up @@ -333,6 +339,8 @@ def run(self):
msg_string = msg_string.replace(":null", "None") msg_string = msg_string.replace(":null", "None")
msg_string = msg_string.replace("namespace\"None", "namespace\":None") msg_string = msg_string.replace("namespace\"None", "namespace\":None")
msg_string = msg_string.replace("\\n", "\\\n") msg_string = msg_string.replace("\\n", "\\\n")
msg_string = msg_string.replace("problem\"None", "problem\":None")
msg_string = msg_string.replace("id\"None", "id\":None")
print "result is: " + msg_string print "result is: " + msg_string
res = None res = None
try: try:
Expand Down Expand Up @@ -370,7 +378,8 @@ def print_result_message(res, printer):
if isinstance(res, str): if isinstance(res, str):
clear_marked_line_numbers() clear_marked_line_numbers()
printer.write('\n[OPERATION FAILED]:' + res + '\n') printer.write('\n[OPERATION FAILED]:' + res + '\n')
elif 'check_deploy_status_response' in res and res['check_deploy_status_response']['result']['success'] == False: elif 'check_deploy_status_response' in res and res['check_deploy_status_response']['result']['success'] == False and 'messages' in res['check_deploy_status_response']['result']:
#here we're parsing a response from the metadata endpoint
res = res['check_deploy_status_response']['result'] res = res['check_deploy_status_response']['result']
line_col = "" line_col = ""
msg = None msg = None
Expand Down Expand Up @@ -400,7 +409,18 @@ def print_result_message(res, printer):
elif failures != None: elif failures != None:
for f in failures: for f in failures:
printer.write('\n[DEPLOYMENT FAILED]: ' + f['name'] + ', ' + f['method_name'] + ': ' + f['message'] + '\n') printer.write('\n[DEPLOYMENT FAILED]: ' + f['name'] + ', ' + f['method_name'] + ': ' + f['message'] + '\n')

elif 'check_deploy_status_response' in res and res['check_deploy_status_response']['result']['success'] == False and 'messages' not in res['check_deploy_status_response']['result']:
#here we're parsing a response from the apex endpoint
res = res['check_deploy_status_response']['result']
line_col = ""
if 'line' in res:
line_col = ' (Line: '+res['line']
mark_line_numbers([int(float(res['line']))])
if 'column' in res:
line_col += ', Column: '+res['column']
if len(line_col) > 0:
line_col += ')'
printer.write('\n[COMPILE FAILED]: ' + res['problem'] + line_col + '\n')
elif 'check_deploy_status_response' in res and res['check_deploy_status_response']['result']['success'] == True: elif 'check_deploy_status_response' in res and res['check_deploy_status_response']['result']['success'] == True:
clear_marked_line_numbers() clear_marked_line_numbers()
printer.write('\n[Deployed Successfully]' + '\n') printer.write('\n[Deployed Successfully]' + '\n')
Expand Down
12 changes: 12 additions & 0 deletions support/app/controllers/execute_controller.rb
@@ -0,0 +1,12 @@
# encoding: utf-8
require SUPPORT + '/lib/mavensmate.rb'

class ExecuteController < ApplicationController

layout "base", :only => [:index]

def index
render "_index"
end

end

0 comments on commit 5291253

Please sign in to comment.