Skip to content

Instantly share code, notes, and snippets.

@tracymiranda
tracymiranda / deleteProjects.py
Created February 10, 2016 13:50
This script runs with Eclipse EASE Jython engine. It deletes the projects created by the createProjects.py script
View deleteProjects.py
# name :Delete fruit projects
# toolbar : Project Explorer
# description : Get rid of the fruit projects
loadModule("/System/Resources")
for name in ["banana", "pineapple", "mango"]:
project = getProject(name)
project.delete(0, None)
@tracymiranda
tracymiranda / createProjects.py
Created February 10, 2016 13:49
This script runs with Eclipse EASE Jython engine. It creates four new projects.
View createProjects.py
# name : Create fruit projects
# toolbar : Project Explorer
# description : Create fruit projects
loadModule("/System/Resources")
for name in ["banana", "pineapple", "mango"]:
createProject(name)
@tracymiranda
tracymiranda / explorer.py
Created February 10, 2016 13:47
This script runs with Eclipse EASE Jython engine. It allows you to start a file browser using the current selection.
View explorer.py
# name : Explore from here
# popup : enableFor(org.eclipse.core.resources.IResource)
# description : Start a file browser using current selection
loadModule("/System/Platform")
loadModule('/System/UI')
selection = getSelection()
if isinstance(selection, org.eclipse.jface.viewers.IStructuredSelection):
selection = selection.getFirstElement()
@tracymiranda
tracymiranda / autosave.py
Last active July 19, 2020 19:11
This script runs with Eclipse EASE Jython engine.It autosaves the current editor every 30 seconds or when the editor is deactivated.
View autosave.py
# Before running this script you will need to turn on the 'Allow Scripts to run code in UI thread'
# setting by checking the box under Window>Preferences>Scripting.
# To run you can right click on the file and select Run As>EASE Script.
# A save message is printed out in the Console view every time an editor is saved.
# To turn off the autosave just stop the script for example, by pressing the
# 'Terminate' red square button in the Eclipse Console view.
import time
loadModule("/System/Platform")
loadModule("/System/UI")
@tracymiranda
tracymiranda / add_readme.py
Created February 10, 2016 12:35
This script runs with Eclipse EASE Jython engine. It adds a README.md file to all open projects in the workspace, noting if they are a java or python project.
View add_readme.py
loadModule('/System/Resources')
for iproject in getWorkspace().getProjects():
if not iproject.isOpen():
continue
ifile = iproject.getFile("README.md")
if not ifile.exists():
contents = "# " + iproject.getName() + "\n\n"
@tracymiranda
tracymiranda / markers.py
Last active February 10, 2016 12:32
This script runs with Eclipse EASE Jython engine. It adds an Eclipse Task Marker for all printStackTrace lines it detects in java files in the workspace.
View markers.py
loadModule('/System/Resources')
from org.eclipse.core.resources import IMarker
for ifile in findFiles("*.java"):
file_name = str(ifile.getLocation())
print "Processing " + file_name
with open(file_name) as f:
for line_no, line in enumerate(f, start=1):
if "printStackTrace" in line: