Anyone that has installed Aptana has probably noticed the console that starts up with the message "Eclipse Monkey JavaScript Console Started." I know for the longest time I wondered what the heck that was. You may have used Eclipse Monkey and not known that you were if you ever accessed anything in the scripts menu option, like Compact Javascript. While it is packaged with Aptana it's actually a separate plugin for Eclipse which you could use outside of Aptana.
I took the opportunity this morning to play around with it some and I have to say I was very impressed with what one could do quite quickly with Eclipse Monkey. I showed my co-worker, Bob, Eclipse Monkey and within 10 minutes he said, "This is sweet" and sent me a new script, which I've included at the bottom of this post, to help take care of the annoying MyEclipse issue on Macs. Aptana has a really nice one for code reviews or presenters that allows you to easily increase and decrease font sizes, lots easier than going through preferences. Another benefit I have found is the ability to do Key Bindings, essentially I can now bind my snippets to keys like I could with Homesite. Basically I have the Eclipse Monkey script with the appropriate key binding type out the text for the snippet to engage. I know its a bit of a hack but at least I can do it. I could just put the correct code into the Eclipse Monkey script itself but then I could not leverage SnipEx server...yet.
/* * Menu: Editors > Personalize Editor Font
* Kudos: Robert Burns (The Kroger Co.)
* License: EPL 1.0
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
* */
function main()
{
var store = Packages.org.eclipse.ui.internal.WorkbenchPlugin.getDefault().getPreferenceStore();
font = Packages.org.eclipse.jface.resource.JFaceResources.getTextFont();
if (font != null)
{
var data = font.getFontData();
if (data != null && data.length > 0)
{
var fontName = getFontName(data[0].getName());
var fontHeight = getFontHeight(data[0].getHeight());
if (fontName != null && fontHeight != null)
{
data[0].setName(fontName);
data[0].setHeight(fontHeight);
}
store.setValue(Packages.org.eclipse.jface.resource.JFaceResources.TEXT_FONT, Packages.org.eclipse.jface.preference.PreferenceConverter.getStoredRepresentation(data));
}
}
}
function getFontName(name)
{
dialog = new Packages.org.eclipse.jface.dialogs.InputDialog(window.getShell(), "Font Name", "Font name?", name, null);
result = dialog.open();
if (result == Packages.org.eclipse.jface.window.Window.OK)
{
return dialog.getValue();
}
}
function getFontHeight(height)
{
dialog = new Packages.org.eclipse.jface.dialogs.InputDialog(window.getShell(), "Font Height", "Font height?", height, null);
result = dialog.open();
if (result == Packages.org.eclipse.jface.window.Window.OK)
{
return dialog.getValue();
}
};
Wednesday, February 06, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment