Hi Tankut,
a command itself is always independend from the UI(menus/toolbars).
It just defines certain command/action in an abstract way.
The thing you really can add to a View is a menu extension.
On that menuContribution in the plugin.xml you can add a visibleWhen flag, where you can define the conditions for showing the menuContribution.
<visibleWhen
checkEnabled="false">
<with
variable="activePart">
<test
property="link to your PropertyTester, which checks the secondary id of the activePart" args="specialSecondaryId1,specialSecondaryId2,specialSecondaryId3">
</test>
</with>
</visibleWhen>
Your PropertyTester could be something like this:
public class SecondaryIdTester extends PropertyTester {
@Override
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
boolean testSucceeds = false;
if(receiver instanceof YourView){
String secondaryId = ((YourView)receiver).getViewSite().getSecondaryId();
for(Object arg : args){
if(secondaryId.equals(arg)){
testSucceeds = true;
}
}
}
return testSucceeds;
}
}
A good overview concerning the usage of PropertyTesters can be found here:
http://wiki.eclipse.org/Command_Core_Expressions#Expressions_and_the_Command_Framework
I hope this helps you and do not hesitate to ask again, if anything is unclear or you need further information.
Best regards,
Simon
[Updated on: Fri, 06 July 2012 23:47]
Report message to a moderator