Posts

Showing posts from March, 2012

Eclipse command framework core expression: Property tester

Image
Addition to Eclipse command framework series, this post explains use of property tester to control command’s enable/visible properties. In earlier post we have tried declarative way to achieve same thing but property tester gives us more control. Property tester is associated with, tester class which implements PropertyTester.java, a namespace and set of property which it supports. We can refer this property tester using its namespace + a property name. It gives you call back to test() method with property name as parameter inside property tester class. We can configure property tester for type of input parameter. Here is sample declaration of property tester extension point < extension point ="org.eclipse.core.expressions.propertyTesters" > < propertyTester class ="com.example.advance.cmd.EditorTester" id ="com.example.advance.cmd.propertyTester1" namespace ="com.example.advance.cm

Eclipse command framework core expression: enable/visible commands

Image
In the previous post of Eclipse command framework core expression series, I have shown having multiple handler for single command and activating only one of then based on context. In this post you will see how to enable/disable command as well as make it visible/invisible. Command framework core expression supports enabling/disabling commands using “enableWhen” phrase as well as make it visible/invisible to your RCP application using “visibleWhen”. You can play around with these phrases to enable/disable/visible/invisible commands. Here I  am going to use same project from previous example .   Lets try “enableWhen” to enable command for particular editor instance. < extension point ="org.eclipse.ui.handlers" > < handler class ="com.example.advance.cmd.Cmd1Handler1" commandId ="com.example.advance.cmd.command1" > < enabledWhen > < with variable ="activeEd

Eclipse command framework core expression : Multiple handlers

Image
Eclipse platform command framework supports core expression to control commands behavior runtime. In this series of posts I have explained different ways of using core expressions . This post explains having multiple handler for same command but activate only one of it at runtime based on some of the condition. Eclipse command framework is based on MVC framework. Command declaration, handler declaration  and contributing command to workbench helps to keep declaration separate from presentation. You can have multiple handlers for same command, but only one will be active at one moment. Core expression provides “activeWhen” declarative clause to activate specific handler for given command based on specific condition. Here is how we use it . I have created a new eclipse plug-in project. I have extended “org.eclipse.ui.editors” extension point to define two simple text editors. Here I am going to define two different handlers for same commands but only one will be active based on edito