Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How can I use IProject.getName() in plugin.xml or plugin.properties file(Hide/show submenu item depending on System property)
icon4.gif  How can I use IProject.getName() in plugin.xml or plugin.properties file [message #662523] Wed, 30 March 2011 22:34 Go to next message
xemox  is currently offline xemox Friend
Messages: 9
Registered: May 2010
Junior Member
Smile I have several projects in Eclipse. And I have a plugin that is activated/executed by popupmenu when you right click on any project.

And I need to hide/show some submenus in in the popupmenu depending on System property. I address it in plugin.xml as follows:

<objectContribution
           adaptable="true"
           id="com.qonline.qolclipse.contribution1"
           objectClass="org.eclipse.core.resources.IProject">
        <action
               class="com.qonline.eclipse.popup.actions.AddQOLNature"
              id="com.qonline.qolclipse.addqolnature"
              label="Add QOL nature"
              menubarPath="com.qonline.qolclipse.main/group1">
        </action>
    	
         <visibility>
           <systemProperty
                 name="qolclipse.connected"
                 value="true">
           </systemProperty>
        </visibility>
     
      </objectContribution> 

. . . . ..
This works fine with single project. I am setting "qolclipse.connected" SystemProperty to true or false when I want to hide or show the action[see code above]. But when I have more than one projects it does not work, because all projects are checking the same <systemProperty> [see above code].

Because of this fact [ all projects are checking the same <systemProperty>], I want to use IProject.getName() in plugin.xml, so that for every project I can have specific Systemproperty with project's name.

I need something like this:

 <systemProperty
                 name="IProject.getName()"
                 value="true">
</systemProperty>


But I coud not find a way how to use the external variable [IProject.getName()] in plugin.xml. I noticed that we can use some contants from plugin.properties, BUT what about variables?

HOW CAN I USE VARIABLE EXPRESSIONS in plugin.xml or plugin.properties?

Could you please inform me if there are any other ways of hiding/showing the submenus. I need <visibility> not <enablement>?

Any guidelines, tips, links, advice.. are appreciated.

Thanks! Smile

Regards,
Xemox

Re: How can I use IProject.getName() in plugin.xml or plugin.properties file [message #662636 is a reply to message #662523] Thu, 31 March 2011 11:26 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Actually, you probably want to set a persistent project property using
the IResources/IProject API. Then use that, since it is per-project.
In objectContributions I believe there's a published filter, like
mentioned on org.eclipse.ui.IResourceActionFilter

If you use <enablement/>, then you will be using core expressions and
the selection will be a collection of IProjects. Then you use something
like:
<iterate ifEmpty="false">
<adapt type="org.eclipse.core.resources.IProject">
// here you can use property testers to test either
// the project persistent property or the project name
// see links in my sig for more information
</adapt>
</iterate>

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Programmatically invoke the import "Existing projects into workspace"
Next Topic:Prevent a view from releasing
Goto Forum:
  


Current Time: Fri Apr 26 02:17:45 GMT 2024

Powered by FUDForum. Page generated in 0.03214 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top