Posted by pookzilla on August 1, 2006
Does this give anyone ideas? *coughscriptingcough*
class MyExecutionListener implements org.eclipse.core.commands.IExecutionListener {
... <snip uninteresting bits > ...
public void preExecute(String commandId, ExecutionEvent event) { if ("org.eclipse.ui.file.save".equals(commandId)) { Command command = service .getCommand("org.eclipse.jdt.ui.edit.text.java.organize.imports"); if (command != null) { ExecutionEvent newEvent = new ExecutionEvent( command, event.getParameters(), event.getTrigger(), event.getApplicationContext()); try { command.executeWithChecks(newEvent); } catch (Exception e) { } } } } }}
Posted by pookzilla on
Summer can be really fun in Eclipse-land. We’ve just released, everyone is on vacation, and the plan for the next release is wide open and largely undefined. It’s time to play with weird and wonderful ideas.
Awhile ago I got it in my head that it might be cool if RCP developers had a tool that would allow them to totally control the plug-ins that their product is based upon. For instance, crop and remove problematic action sets, re-organize preference pages, rename editors, etc. One idea I had to accomplish this idea was to hook into the platform the ability to run the registry through a stylesheet on startup. I managed to get this working in the most minimal way awhile ago and recently people have been asking to see it. Until there is a suitable PR/plan item to attach it to I’ll just post the patch here for people to try out. No warranty, no support, etc etc. This patch was made against 3.2 but I’ve confirmed that it works with the latest code from head as of August 1 2006.
After applying the patch you can easily see the effects by launching your runtime workspace with the -Declipse.registryStylesheet argument. The value of this property should be a path to an XSL stylesheet. Below is an example stylesheet that can be used to remove the “line delimiter” action set from the file menu.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="actionSet[@id='org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo']"> </xsl:template> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template></xsl:stylesheet>