Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?)(When I unselect a c/c++ project with control button and then right click it with mouse Build Project doesnt appear as enabled !)
CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1707984] Fri, 11 September 2015 08:23 Go to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
When I unselect a project by pressing control key and left button of mouse, it appears as unselected not blue higlighted. Now When it is unselected if you right click the c/c++ project then the Build Project is not enabled. This doesnt appear at the Java project ! But only at c/c++ project.

This happens in case when the selection happens to be "<empty selection>" then the setEnabled(updateSelection(selection)) expression is false . But the debuging also shows that the same code line can get the IStructeredSelection as project itself. So when It is evaluating for this button the IStructeredSelection is <empty selection> at for class BuildAction.isEnabled() method line 239.

Please look at the debugScreen screenshot for more information.

is this a bug ? How can we solve it ? Please dont hesitate to ask for more information.

Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1707990 is a reply to message #1707984] Fri, 11 September 2015 09:20 Go to previous messageGo to next message
David Vavra is currently offline David VavraFriend
Messages: 629
Registered: October 2012
Senior Member
Yeah. That's strange and probably a bug.
When I tried it, the project became selected with the right click but Build Project was disabled in the context menu.
This condition remains until another project is enabled. The condition is also cleared by selecting the same project with a left click.

Yet another petty although easily circumvented annoyance to add to the rather long list of annoyances.


Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1708004 is a reply to message #1707990] Fri, 11 September 2015 11:34 Go to previous messageGo to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
This happens similarly when moving a projects file and then pressing right click on the project to build it. Similarly When Includes is pressed and then right click to the project yields the same error. What should I do ? Should I open a bug at eclipse bugzilla ?

ilke
Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1708012 is a reply to message #1708004] Fri, 11 September 2015 12:53 Go to previous messageGo to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
It appears that already similar bugs are reported :

https://bugs.eclipse.org/bugs/show_bug.cgi?id=471917
https://bugs.eclipse.org/bugs/show_bug.cgi?id=435208

ilke
Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1709440 is a reply to message #1708012] Mon, 28 September 2015 12:37 Go to previous messageGo to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
How can I programatically (or via eclipse plugin.xml) edit context menu of a project when It is right clicked in Project Explorer so that I can make the Build Action enabled in order to solve this problem.

I have tried MenuManager but it returns the top menu ? I want to acess the pop-up menu when it is right clicked on a project.

http://stackoverflow.com/questions/11410589/how-can-i-add-submenus-for-pop-up-menu-programatically

In this page above It says about IContributionRoot additions class and then it adds to this class via

  CommandContributionItem itemBB = new CommandContributionItem(pBB);
   itemBB.setVisible(true);
  additions.addContributionItem(itemBB, null);


This looks like a solution but how can I access IContributionRoot additions programmatically at the source code ?

Any idea ?

ilke

[Updated on: Wed, 30 September 2015 11:52]

Report message to a moderator

Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1709852 is a reply to message #1709440] Thu, 01 October 2015 13:54 Go to previous messageGo to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
Can this be a solution ?

https://wiki.eclipse.org/Menu_Contributions/Search_Menu

ilke


Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1711198 is a reply to message #1709852] Wed, 14 October 2015 06:23 Go to previous messageGo to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
I solved the bug via an actionProvider (enablement for a instanceof IProject.) Here in the class that I extended from CommonActionProvider at the method setContext I got the command via commandService and getCommand method. Then calling buildCommand.isEnabled(); solved the bug.

[Updated on: Wed, 14 October 2015 07:25]

Report message to a moderator

Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1711221 is a reply to message #1711198] Wed, 14 October 2015 08:01 Go to previous messageGo to next message
Sebastien Leblanc is currently offline Sebastien LeblancFriend
Messages: 1
Registered: October 2015
Junior Member
Hi ilke,

I'm facing same issue with Eclipse CDT 8.6.0 integrated in Luna platform.
Could you please share your code of the workaround ?

Regards,
Sebastien
Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1712262 is a reply to message #1711221] Thu, 22 October 2015 13:34 Go to previous messageGo to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
I can not share the code because We can not copy the code out of the computer. But I will like to answer your questions, I have posted the solution in previous comment. Where have you got stucked. Simply do a new actionProvider in plugin.xml there enable it for every IProject type.

Then in the method setContext of class that you extended from CommonActionProvider that pointed it at plugin.xml where you added the new ActionProvider, simply call the buildCommand.isEnabled().

get the build command via commandService and getCommand method.

Check this link to get the CommandService.

http://stackoverflow.com/questions/17061426/how-to-get-icommandservice-object-when-workbench-is-not-available

Command command = commandService
.getCommand("alexandraniculai.commands.myToggleCommand");

here you have to type the command Id which is :

IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT for this command.

check this link
https://alexandraniculai.wordpress.com/2010/08/23/how-to-get-a-command-object-in-eclipse-rcp-or-plugins/




Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1712263 is a reply to message #1711221] Thu, 22 October 2015 13:35 Go to previous messageGo to next message
ilke Muhtaroglu is currently offline ilke MuhtarogluFriend
Messages: 33
Registered: September 2015
Member
Please dont hesistate to ask. This is a solution via eclipse plugin.xml not a solution to the bug itself in eclipse code.

[Updated on: Thu, 22 October 2015 13:36]

Report message to a moderator

Re: CPP (C) Project not selected right click shows Build Project not enabled. (is Bug ?) [message #1775436 is a reply to message #1712263] Mon, 30 October 2017 08:50 Go to previous message
hankin han is currently offline hankin hanFriend
Messages: 1
Registered: October 2017
Junior Member
hi, ilke

I'm facing same issue with Eclipse CDT 9.2.1. refer to your solution´╝î but it is not working for me.


public class ActionProvider extends CommonActionProvider {
    @Override
    public void setContext(ActionContext context) {
        ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
                .getService(ICommandService.class);
        Command buildCommand = commandService
                .getCommand("IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT");
        buildCommand.isEnabled();
    }
}


   <extension
         point="org.eclipse.ui.navigator.navigatorContent">
      <actionProvider
            class="com.templates.ActionProvider"
            id="com.templates.ActionProvider">
         <enablement>
            <instanceof
                  value="org.eclipse.core.resources.IProject">
            </instanceof>
            <or>
               <instanceof
                     value="org.eclipse.core.resources.IProject">
               </instanceof>
            </or>
         </enablement>
      </actionProvider>
   </extension>
   <extension
         point="org.eclipse.ui.navigator.viewer">
      <viewerActionBinding
            viewerId="org.eclipse.ui.navigator.ProjectExplorer">
         <includes>
            <actionExtension
                  pattern="com.templates.ActionProvider">
            </actionExtension>
         </includes>
      </viewerActionBinding>
   </extension>



The above is the implement of class and plugin.xml. Could you please help me to check code above?


[Updated on: Tue, 31 October 2017 07:30]

Report message to a moderator

Previous Topic:How to Embed CORBA in Eclipse version?
Next Topic:Dynamic Printf doesn't work
Goto Forum:
  


Current Time: Sat Dec 16 09:27:37 GMT 2017

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

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