Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add support to create MavensMate project from existing directory (pro…

…ject MUST be in MM_WORKSPACE)
  • Loading branch information...
commit f3c2cd3751b26ee1d83ed1b455c79877a28a982a 1 parent e60285a
Joe Ferraro authored
3  Side Bar.sublime-menu
View
@@ -5,7 +5,8 @@
"children":
[
{ "caption": "Delete Selected Files from Salesforce Server", "command": "delete_metadata", "args": {"files": []} },
- { "caption": "Refresh From Server", "command": "refresh_directory", "args": {"dirs": []} }
+ { "caption": "Refresh From Server", "command": "refresh_directory", "args": {"dirs": []} },
+ { "caption": "Create MavensMate Project", "command": "create_mavens_mate_project", "args": {"dirs": []} }
]
}
]
8 commands/new_project_from_directory.rb
View
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby -W0
+require File.dirname(File.dirname(__FILE__)) + "/constants.rb"
+include Constants
+require SUPPORT + "/environment.rb"
+require CONTROLLERS_ROOT + "/project_controller.rb"
+ENV["MM_CURRENT_PROJECT_DIRECTORY"] = ARGV[0]
+ENV["MM_WORKSPACE"] = ARGV[1]
+dispatch :controller => "project", :action => "index_new_from_existing", :user_action => "new"
59 mavensmate.py
View
@@ -38,9 +38,8 @@ def stop_local_server():
cmd_b = ruby+" -r '"+mm_dir+"/support/lib/local_server.rb' -e 'MavensMate::LocalServer.stop'"
os.system(cmd)
-def generate_ui(ruby_script, arg0):
- cmd = ruby+" '"+mm_dir+"/commands/"+ruby_script+".rb' '"+arg0+"'"
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
+def generate_ui(ruby_script, args):
+ p = subprocess.Popen(ruby+" '"+mm_dir+"/commands/"+ruby_script+".rb' "+args+"", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
if p.stdout is not None :
msg = p.stdout.readlines()
temp = tempfile.NamedTemporaryFile(delete=False, prefix="mm")
@@ -138,45 +137,87 @@ def run (self, dirs):
thread.start()
handle_threads(threads, printer, handle_result, 0)
+#creates a MavensMate project from an existing directory
+class CreateMavensMateProject(sublime_plugin.WindowCommand):
+ def run (self, dirs):
+ directory = dirs[0]
+
+ if directory.endswith("/src"):
+ printer = PanelPrinter.get(self.window.id())
+ printer.show()
+ printer.write('\n[OPERATION FAILED] You must run this command from the project folder, not the "src" folder\n')
+ return
+
+ dir_entries = os.listdir(directory)
+ has_source_directory = False
+ for entry in dir_entries:
+ if entry == "src":
+ has_source_directory = True
+ break
+
+ if has_source_directory == False:
+ printer = PanelPrinter.get(self.window.id())
+ printer.show()
+ printer.write('\n[OPERATION FAILED] Unable to locate "src" folder\n')
+ return
+
+ dir_entries = os.listdir(directory+"/src")
+ has_package = False
+ for entry in dir_entries:
+ if entry == "package.xml":
+ has_package = True
+ break
+
+ if has_package == False:
+ printer = PanelPrinter.get(self.window.id())
+ printer.show()
+ printer.write('\n[OPERATION FAILED] Unable to locate package.xml in src folder \n')
+ return
+
+ start_local_server()
+ temp_file_name = generate_ui("new_project_from_directory", "'"+directory+"' '"+mm_workspace()+"'")
+ launch_mavens_mate_window(temp_file_name)
+
+#launches the execute anonymous UI
class ExecuteAnonymousCommand(sublime_plugin.ApplicationCommand):
def run(command):
start_local_server()
- temp_file_name = generate_ui("execute_anonymous", mm_project_directory())
+ temp_file_name = generate_ui("execute_anonymous", "'"+mm_project_directory()+"'")
launch_mavens_mate_window(temp_file_name)
#displays edit project dialog
class EditProjectCommand(sublime_plugin.ApplicationCommand):
def run(command):
start_local_server()
- temp_file_name = generate_ui("edit_project", mm_project_directory())
+ temp_file_name = generate_ui("edit_project", "'"+mm_project_directory()+"'")
launch_mavens_mate_window(temp_file_name)
#displays new project dialog
class NewProjectCommand(sublime_plugin.ApplicationCommand):
def run(command):
start_local_server()
- temp_file_name = generate_ui("new_project", mm_workspace())
+ temp_file_name = generate_ui("new_project", "'"+mm_project_directory()+"'")
launch_mavens_mate_window(temp_file_name)
#displays deploy dialog
class DeployToServerCommand(sublime_plugin.ApplicationCommand):
def run(command):
start_local_server()
- temp_file_name = generate_ui("deploy_to_server", mm_project_directory())
+ temp_file_name = generate_ui("deploy_to_server", "'"+mm_project_directory()+"'")
launch_mavens_mate_window(temp_file_name)
#displays new project dialog
class CheckoutProjectCommand(sublime_plugin.ApplicationCommand):
def run(command):
start_local_server()
- temp_file_name = generate_ui("checkout_project", mm_workspace())
+ temp_file_name = generate_ui("checkout_project", "'"+mm_project_directory()+"'")
launch_mavens_mate_window(temp_file_name)
#displays unit test dialog
class RunApexUnitTestsCommand(sublime_plugin.ApplicationCommand):
def run(command):
start_local_server()
- temp_file_name = generate_ui("run_apex_tests", mm_project_directory())
+ temp_file_name = generate_ui("run_apex_tests", "'"+mm_project_directory()+"'")
launch_mavens_mate_window(temp_file_name)
#replaces local copy of metadata with latest server copies
2  packages.json
View
@@ -10,7 +10,7 @@
"platforms": {
"osx": [
{
- "version": "1.2.1",
+ "version": "1.2.2",
"url": "https://nodeload.github.com/joeferraro/MavensMate-SublimeText/zipball/master"
}
]
126 support/app/views/project/_project_new_from_existing.html.erb
View
@@ -0,0 +1,126 @@
+<div id="result_output" class="error">
+ <div id="result_wrapper" style="padding:0px 10px;">
+ <div class="alert-message error" style="display:none;">
+ <p id="error_message"></p>
+ </div>
+ <div class="alert-message success" style="display:none;">
+ <p id="success_message"></p>
+ </div>
+ </div>
+</div>
+
+
+<div class="content">
+ <ul class="tabs">
+ <li class="active"><a id="project_details_tab" href="#form">Project Details</a></li>
+ </ul>
+
+ <div class="pill-content">
+ <div id="form" class="active">
+ <form class="form-stacked">
+ <fieldset>
+ <div class="clearfix">
+ <label for="pn">Project Name</label>
+ <input class="xlarge" size="100" type="text" id="pn" value="<%= pname %>" disabled="true">
+ </div>
+ <div class="clearfix">
+ <label for="un">Salesforce Username</label>
+ <input class="xlarge" size="100" type="text" id="un">
+ </div>
+ <div class="clearfix">
+ <label for="pw">Salesforce Password</label>
+ <input class="xlarge" size="100" type="password" id="pw">
+ </div>
+ <div class="clearfix">
+ <label for="server_url">Server URL</label>
+ <select id="server_url">
+ <option>https://www.salesforce.com</option>
+ <option>https://test.salesforce.com</option>
+ </select>
+ </div>
+ </fieldset>
+ </form>
+ </div>
+
+ </div>
+</div>
+
+<form class="form-stacked" id="action_buttons">
+ <fieldset style="padding-top:0px;">
+ <div class="actions">
+ <input type="button" id="btnSubmit" class="btn primary" value="Create MavensMate Project" onclick="newProjectFromExistingDirectory();">
+ &nbsp;
+ <button type="reset" class="btn" onclick="window.close();">Cancel</button>
+ </div>
+ </fieldset>
+</form>
+
+<div class="twipsy deploy_loading">
+ <div class="loading_indicator"></div>
+</div>
+<div class="deploy_wait_description">
+ Indexing metadata...
+</div>
+
+ <script type="text/javascript">
+ var mm_cpd = '<%= ENV["MM_CURRENT_PROJECT_DIRECTORY"] %>';
+ var has_indexed_metadata = <%= File.exist? "#{ENV["MM_CURRENT_PROJECT_DIRECTORY"]}/config/.org_metadata" %>;
+
+ function newProjectFromExistingDirectory() {
+ console.log('creating mavensmate project')
+ $.ajax({
+ type: "POST",
+ url: "http://127.0.0.1:7777/project/existing",
+ data: {
+ pn: $("#pn").val(),
+ un: $("#un").val(),
+ pw: $("#pw").val(),
+ server_url: $("#server_url").val(),
+ where: "<%= ENV['MM_WORKSPACE'] %>",
+ existing_location: "<%= existing_directory %>"
+
+ },
+ beforeSend: function() { showBlanket(); },
+ complete: function(data){
+ console.log(data)
+ var response = JSON.parse(data.responseText)
+ if (response["success"] == false) {
+ $("#error_message").html(response["message"])
+ $(".alert-message.success").hide()
+ $(".alert-message.error").show()
+ } else {
+ $("#success_message").html(response["message"])
+ $(".alert-message.error").hide()
+ $(".alert-message.success").show()
+ }
+ hideBlanket();
+ }
+ });
+ }
+
+ $(function() {
+ //instantiate tabs
+ $('.tabs').tabs();
+
+ var resizeHeight = $(".content").height();
+ resizeAndCenterWindowByHeight(resizeHeight);
+
+ $(window).resize(function() {
+ $(".content").height($(window).height() - 175)
+ });
+
+ $("#pn").val("<%= pname %>");
+
+ //resize elements
+ $(".content").height($(window).height() - 175)
+
+ $(window).resize(function() {
+ $(".content").height($(window).height() - 175)
+ });
+
+ });
+
+ function showBlanket() { $('.deploy_loading').fadeIn(); }
+
+ function hideBlanket() { $('.deploy_loading').hide(); }
+ </script>
Please sign in to comment.
Something went wrong with that request. Please try again.