How to save file using Eclipse Monkey? - eclipse

I've recently started working with Aptana and Eclipse Monkey. What I want to do now is to create a script that saves a file then uploads it to a FTP.
Problem is that Eclipse Monkey is VERY poorly documented and Google returned only unrelated results.
I've made it upload the file, but I need the script to save the file before uploading.
sync.uploadCurrentEditor();
Do you know any resource for Eclipse Monkey with methods,etc ?

Check this out, it has the solution for your problem:
http://forums.aptana.com/viewtopic.php?t=5216
Edit; to be more specific;
You need to add the following line into the meta-data piece at the top, so the script knows the reference 'editors':
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
After you've done that, you need to add the following line right before the sync. stuff;
editors.activeEditor.save();
That's it :)

Related

How to convert a SB3 file to an EXE

I'm creating a game on Scratch 3, however, when I'm finished with it, I want to convert it to an .exe file. How do I do this?
I've been interested in game development for a long time, and have even tried Unity before, but I'm just a beginner meaning it was too difficult for me. So I turned to Scratch.
Yes, It is possible! ...But it's kinda complex,
Bear with me!
First, Take your sb3 file and convert it into a sb2. To do this I recommend using rexscratch's sb3tosb2 tool. Found here: https://github.com/RexScratch/sb3tosb2
Make sure you have python installed, if you don't, google how to install it. (it's easy).
Next, Click Clone or Download then click Download ZIP. Once that is downloaded, Open the zip, go to the next folder, and execute sb3tosb2.py . This will then ask for a sb3 file, Navigate to the sb3 file you have and select it. It may say it wants to work in compatibility mode, if it does, Just accept it. It will finish up and ask you where to put a sb2 file, just place it on your desktop and name it something.
Secondly, We need to use a program called junebeetle, Don't worry, it's a web based one, found here: https://junebeetle.github.io/converter/online/
Click open scratch file. It will ask for a sb2, Navigate to where you put the sb2 file and open it. If you want you can customize how it will open, you can. I like to use the auto start function, and fullscreen. Don't mess with the resolution unless you know not how to screw-up aspect-ratios. Then click "Convert to SWF" This will then download the SWF version the scratch game, simply name it what you want and leave it.
Finally, you need to convert the SWF file to an EXE, There are plenty of ways to do this, but for ease, I recommend using a lite file converter. SWF Tools is a good one found here: https://sourceforge.net/projects/swftools/files/SwF_To_eXe/Swf2eXe_Latest.zip/download
Let it download and then extract the zip file's content to your desktop or downloads folder. Then open the exe file inside the folder from the zip file you just extracted.
Almost there! Click "Add a file" Then, you guessed it, Navigate to the SWF file that was spat out from the conversion of the sb2. Then click "Convert" Let it do its thing, and soon it will finish. Boom, Done. To find your exe file, go to where you stored the SWF to EXE converter, go to the "Output" Folder, and infront of you, is your EXE File! Note: Your anti-virus might freakout, this is normal when making new programs.
Also, Some fonts may break, This is just a side effect of the sb3 to sb2 conversion due to the fact that there is currently no way to convert sb3 to SWF.
Hopefully that was easy enough to understand. It is a complicated process, But yields results!
If you have any issues, Just Ask! I can help!
You could use the TurboWarp Packager. It's free and safe. https://packager.turbowarp.org/
There might not be a specific or direct way to convert a Sb3 File to an exe file but You can do it indirectly in a few steps which might be kind of lengthy but works.
When your SB3 project is done, go to https://sheeptester.github.io/htmlifier/
And convert your sb3 file to html.
From there you can convert the html file you got just now to an exe file, but not as you might expect it to. You cannot convert an html page to an exe file so what you can do is add the html webpage (the scratch game now converted to a html webpage) as an 'embed' file in the software such as, like Unity or Visual Basic, as they allow html webpages to be embedded in a project. Then you can add features and stuff, then publish or export your project as an exe file.
I know the process is really lengthy and I practically just wrote a long boring thesis but this might be the only way you can convert scratch to exe.
Hope my answer helps!
Hasta La Vista
Convert your Scratch project to HTML using Scratch HTMLifier: https://sheeptester.github.io/words-go-here/htmlifier/
Download NW.js and put its files (nw.exe, ...) in a directory. Create a package.json file in that directory that should look like this:
{
"name": "Project",
"main": "project.html"
}
(replace Project with the name of your project and project.html with the name of your HTML file).
Make sure that your project runs when you start nw.exe.
Use any tool to turn your folder into a self-extracting archive.
See also: https://scratch.mit.edu/discuss/topic/341617/
use https://packager.turbowarp.org/
Using simple setting you can export without any problems.
This post is marked obsolete because the content is out of date. It is not currently accepting new interactions.
Currently, there is no software or smart javascript tricks that can convert .sb3 files into .exe files. You could use an .sb2 file but you need to use Scratch 2.0. There are developers working on conversion programs that do .sb3 to .exe but that will take a while. I would recommend using Scratch 2.0 if you want to convert your Scratch games to an executable.

Groovy debugger out of sync

I am having a difficulty while attempting to debug some code in grails. It is difficult to put into text, so I have posted a screencast showing exactly what the problem is here. In short, while I am debugging the debugger starts jumping from place to place and not following the program logic I have in place. The only other similar question I have found is a year old, had no solution, and can be found here.
The best guess I have so far is that the debugger is displaying the text I have typed in, but is actually executing an older version of the class file which it has cached somewhere. Therefore, I tried:
cleaning the project
manually deleting all of the class files from the target folder and from the target-eclipse folder
Searching my entire hdd for additional files with similar names
removing my project from the workspace and re-adding it
closing and reopening the IDE
grails refresh-dependencies
Importing the project into a new IDE (I was using GGTS, I switched to IntelliJ)
None of those solutions had any effect. I realized that the issue was in a .groovy file, and I was writing almost pure Java, so I deleted the .groovy file, and re-created the class in a .java file. That solved my problem. Unfortunately I am having the problem again, and this time it is in a controller that heavily relies on the grails framework, so that solution is not an option. Other than also being in a .groovy file, another similarity is that the code breaks on an if statement.
My next steps:
Verify that the application is not executing the code I see by using print functions to monitor actual execution flow.
comment out the entire function and re-add functionality one line at a time to see if I can see what breaks it.
Delete the .groovy file, and re-create it as another .groovy file.
Any help is appreciated, and since I can't find any answers online I will continue to update this question as I learn more.
See my comment on the jira issue that you raised. You have found a problem with the groovy compiler and how it calculates line numbers. This is not a problem with executing the wrong class files or using a broken debugger. The debugger is doing exactly what it is expected to do. It is the compiler that is providing erroneous line number information.
The next step, as described in the issue, is to provide a simple project that recreates the bug. I tried to do so myself, but could not. So, please supply something that we can work with. Then we can notify the groovy compiler team.

Any way to disable syntax checking for a project?

I created a project "Sample Code"... here I just paste sample code... much of it is snippets that won't compile.
Is there some project-specific setting I can make so that Eclipse doesn't try to compile it?
I would prefer not to have the source code littered with red error markers.
Put your code in a non-java project, ie a general project.
Downside: you will have to create package directory structure (unless you can copy and paste from somewhere else).
Upside: it won't try to compile.
MY SOLUTION
ok, this is not an exact solution to my problem... but it is another way to do it and I kinda like it now...
I simply forget about using Eclipse to store the sample java files!
I found a good program CodeBox for Mac to store code snippets and I'm sure there exist such things for Windows, Linux too...
there interesting thing is that when I choose from this program to open the java snippet file (.java) in an external editor (Eclipse), it will open in Eclipse without any Syntax checking... wohoo! no squiggly lines
Because of this, it is not full blown code highlighting... classes and variables same color... but that's ok.. still quite readable. Much more than if it was in Eclipse with syntax highlighting running on it...
So basically, if you want to get rid of these red squiggles... one way to do it is don't keep sample .java (or other language) files in a project in Eclipse... simply keep them in the filesystem or code storage app and open them with Eclipse when you want to view them.
Depending on how you prefer to structure your project:
you could put your java files into a separate folder that is not configured as a source folder. There is an entry in the eclipse help on how to configure your build path.
or you can set exclusion-patterns in the build configuration, so that specific packages or files that follow a pattern you define don't get compiled.
Yet another way to handle your snippets could be to use a Scrapbook page.
Eclipse won't highlight anything in a scrapbook page but you can select code parts inside the page and execute them isolated. That's nice if you're experimenting and don't want to set up a whole class with imports and methods just to see if a specific snippet works as expected.

Insert template into every source file in an Eclipse project?

Is there a tool, option or script to insert a custom template into the header of every existing source file within an Eclipse project?`
Some background information
I have very recently open-sourced a small application written for a university assignment. Initially the source files did not require any explicit license or author information. But now I am releasing the code I would like to place this information in the header of each Java source file.
I know Eclipse has the capability of inserting a custom template in each new file, and I will be doing this from now on. But there is around 60 existing .java files within which I wish to place this header. While that is not a huge number, I really don't fancy repeating the same cut and paste operation 60 times if there's a lazier way to do it.
P.S. I couldn't think up any better tags for this question, suggestions welcome.
You may want to check out JAutodoc on sourceforge. http://jautodoc.sourceforge.net/
Specifically, check out the section entitled File Header
Hope this helps.

How to Change Netbeans Fonts and Colors Preview Document?

Within the Netbeans 6.5's Tools -> Options -> Fonts & Colors -> Syntax dialog, you have the ability to change the look and feel of the Netbeans text editor. When you select a language, you are presented with a preview of your font/color scheme. However, when I preview Java, there are far more options for syntax changes than are being displayed in that preview window. If I were able to view a more robust piece of code, I'd be able to see the immediate effect of more of the options.
How can I supply a preview document to view my font/color changes?
UPDATE:
After looking into this some more, I've been able to narrow down the problem a bit. From what I can tell, everything in Netbeans is considered a plugin. The GUI editor is a plugin, and even the text editor is a plugin. This means that what ever piece of Netbeans that actually analyzes Java code and does syntax highlights is also a plugin (since Java is just one of many languages Netbeans highlights, it makes sense this is a plugin).
I think fromvega is on the right track with his suggestion. The tutorial for creating a manifest file editing plugin pointed me in the right direction. The tutorial eludes to a file used as a sample document used for font/color previews. It tells you how to create one inside this new plugin project. (Located in "Registering the Options in the NetBeans System Filesystem", part 4. About 4/5 of the way down the page.)
My next line of thought was to look for the Java syntax editing mode plugin and find this file and update it with a richer example file. I looked in the installation directory and came up empty, but I found what looks like the appropriate files within my user settings directory. There is a config directory with a lot of subfolders within my user directory (Windows: C:\Documents and Settings\saterus.netbeans\config).
I've been poking around inside this directory a bit, but have only found the xml files the manifest tutorial talks about. I have been unable to find the extensionless sample file for the Java plugin that I believe should be there.
Since I've hit a brick wall for the moment, I thought I'd toss it back to the SO community and see if you guys might make the last leap and find the solution.
Just for anyone who wants to alter this themselves it is possible on a unix machine to use grep to locate the file i.e.
grep -lr "some part of the current sample code" /path/to/netbeans
I used this method to locate the ruby example filename and from that identified that it is kept in org-netbeans-modules-ruby.jar as a file called RubyExample. By simply altering that file I was able to construct a better sample file for my own use.
Hope this helps someone!
The document which is displayed (for each mime type) is specified in a particular folder in the "system file system" (which is a NetBeans concept which is a virtual file system composed from contributions from individual modules; this is how functionality is dynamically registered in NetBeans).
Modules typically specify their system file system contributions in a file named "layer.xml" in the plugin. The create plugin templates typically offer to create this for you.
For example, here's how the Python example is registered:
<filesystem>
...
<folder name="OptionsDialog">
<folder name="PreviewExamples">
<folder name="text">
<file name="x-python" url="PythonExample.py"/>
</folder>
</folder>
...
Here, PythonExample.py is a sample file in the same directory as the layer file.
Therefore, what you need to do is create a plugin which overrides the existing registration(s) for the mime type(s) you care about and provide alternate sample documents. You may need to hide the existing registration first (see the _hidden
part from http://doc.javanb.com/netbeans-api-javadoc-5-0-0/org-openide-filesystems/org/openide/filesystems/MultiFileSystem.html ).
Hopefully this guides you in the right direction.
However, in thinking about it, we probably ought to make the preview area editable - so people can cut & paste whatever codefragment they care about right in there. This wouldn't be persistent, so whenever you change languages you get the original samples back - but it provides a quick way to see your own code. This shouldn't be just for the Fonts & Colors customization, but for the Formatting preview panels as well.
I've filed an issue against NetBeans for this:
http://www.netbeans.org/issues/show_bug.cgi?id=155964
-- Tor
I think you can only accomplish that with a new plugin, since you need somekind of parsing to define what is what.
Give a look a these tutorials, I haven't read them in details but they seem to show you how to do what you want:
http://platform.netbeans.org/tutorials/nbm-mfsyntax.html
http://www.antonioshome.net/kitchen/netbeans/nbms-coloring.php