Auto upload on save - bug?

A place for those developing Aptana plugins, scripts or extending the IDE to gather and discuss extending Studio beyond the standard features.

Moderator: Aptana Staff

Re: Auto upload on save - bug?

Postby aikar » Wed Aug 26, 2009 7:51 pm

I also can not get the script to load in my script view.

I created a scripts folder in Aptana folder and in my project folder and neither work.

I recently put in a support ticket about using PHP Natures on SFTP Opened files, however If i could make my files auto sync that would effectively be the same thing and give me the ability to use php natures.

we need some updated info on scripts in 1.5 :(
aikar
 
Posts: 2
Joined: Fri Aug 21, 2009 2:54 pm

Re: Auto upload on save - bug?

Postby jaya_ballard » Fri Sep 04, 2009 12:48 pm

First things first: To enable auto upload on save for all your projects
(no need for a scripts folder in you project)

To enable this do the following:
Window => Show Apatana View => Scripts

Normally to the right will popup a Scripts window, navigate to: Synchronize

rightclick on "Upload current file on save" and click "Edit script"

here comes the 'tricky part' you have to add a comment to make it work (weird, comments shouldn't have any effect on the code)

you have to add this comment:
Listener: commandService().addExecutionListener(this);

so the TOP part of the script looks like this (don't touch the rest of the code):

Code: Select all
/*
* Currently an example script (disabled)> Copy as your own script, and modify
* the Listener command as shown below
*
* Listener: commandService().addExecutionListener(this);
* Menu: Synchronize > Upload Current File On Save
* Kudos: Ingo Muschenetz
* License: EPL 1.0
* DOM: http://localhost/com.aptana.ide.syncing.doms
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
*/


After that it's best to restart Aptana (maybe not needed but just in case :)

As for "I updated to aptana 1.5 and it doesn't work anymore" : I believe Aptana 1.5 updates the default scripts (overruling the changes made above) so you have to make the above change again ...

Hope that helps
jaya_ballard
 
Posts: 2
Joined: Fri Sep 04, 2009 12:33 pm

Re: Auto upload on save - bug?

Postby jaya_ballard » Fri Sep 04, 2009 12:52 pm

Maybe this is not the proper way to do it the right way,

but aren't we sometimes happy when "it just works"

Sidenote: The proper way is to copy this script to the top project scripts folder.
But I don't like it when my editor interferes with my 'project' when working with cvs or when you store all your javascript files in a 'scripts' folder there suddenly is a script that serves your ide and is totally useless for your webproject,

sure you can cloack it and cvsignore the file, but yet again, I don't want to alter my workspace just for and IDE who requires a scripts folder in your project directory.

(same goes for all the .tmp* files piling up your project when uploading files to the server)

But hey, this is by far the best php ide!
jaya_ballard
 
Posts: 2
Joined: Fri Sep 04, 2009 12:33 pm

Re: Auto upload on save - bug?

Postby neolord » Fri Sep 04, 2009 9:59 pm

This worked in my Eclipse 3.5 with Aptana 1.5 Plugin

Code: Select all
/*
* Currently an example script (disabled)> Copy as your own script, and modify
* the Listener command as shown below
*
* Listener: commandService().addExecutionListener(this);
* Menu: Autosave > Do
* Kudos: Ingo Muschenetz
* License: EPL 1.0
* DOM: http://localhost/com.aptana.ide.syncing.doms
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
*/

// Add  * Listener: commandService().addExecutionListener(this); to the top of this file to enable it

/**
* Returns a reference to the workspace command service
*/

function main() {}

function commandService()
{
   var commandServiceClass = Packages.org.eclipse.ui.commands.ICommandService;

   // same as doing ICommandService.class
    var commandService = Packages.org.eclipse.ui.PlatformUI.getWorkbench().getAdapter(commandServiceClass);
    return commandService;
}


/**
* Called before any/every command is executed, so we must filter on command ID
*/
function preExecute(commandId, event) {}

/* Add in all methods required by the interface, even if they are unused */
function postExecuteSuccess(commandId, returnValue)
{

   // if we see a save command
   if (commandId == "org.eclipse.ui.file.save")
   {
      sync.uploadCurrentEditor();

      /* Replace above line if you'd like to limit it to just certain projects
      var fileName = editors.activeEditor.uri;
      if(fileName.match(/projectName/ig))
      {
         sync.uploadCurrentEditor();
      }
      */
    }
}

function notHandled(commandId, exception) {}

function postExecuteFailure(commandId, exception) {}


I've put it into folder 'scripts' in my project, set up the synchronization over SFTP and then run that script while focused in the editor of one of the project files
neolord
 
Posts: 1
Joined: Fri Sep 04, 2009 9:58 pm

Previous

Return to Customizing and Extending Studio