Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Filter popup on project nature
Filter popup on project nature [message #806232] Fri, 24 February 2012 18:22 Go to next message
Charlie Kelly is currently offline Charlie KellyFriend
Messages: 276
Registered: July 2009
Senior Member
Hi,

How can I filter a menu contribution for popup menus so that it only
appears when a project contains a particular project nature?

Thanks

Charlie
Re: Filter popup on project nature [message #806327 is a reply to message #806232] Fri, 24 February 2012 20:48 Go to previous message
Charlie Kelly is currently offline Charlie KellyFriend
Messages: 276
Registered: July 2009
Senior Member
Solved problem by using a class the implements
ExtensionContributionFactory using the following method

@Override
public void createContributionItems(IServiceLocator iServiceLocator,
IContributionRoot iContributionRoot)
{
try
{
ISelection iSelection =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
if (null == iSelection)
throw new Exception ("iSelection is null");
if (! (iSelection instanceof TreeSelection))
throw new Exception ("iSelection is NOT instanceof TreeSelection");
TreeSelection treeSelection = (TreeSelection) iSelection;
@SuppressWarnings("rawtypes")
List tempList = treeSelection.toList();
Object tempObject = tempList.get(0);

IFile iFile = null;
if (! (tempObject instanceof IFile) )
return;
iFile = (IFile) tempObject;

IProject iProject = iFile.getProject();
boolean propellerNatureFlag = iProject.hasNature(PropellerNature.ID);
if (! propellerNatureFlag )
return;

// IPath fullPath = iFile.getFullPath();
String fileExtension = iFile.getFileExtension();

String properEndingString =
PropellerConstants.CONFIGURATION_EDITOR_EXTENSION;
boolean properExtensionFlag = fileExtension.equals(properEndingString);
if (! properExtensionFlag)
return;

CommandContributionItemParameter commandContributionItemParameter =
new CommandContributionItemParameter(iServiceLocator, null,

"com.parallax.propeller.gcc.ui.commands.generate_scripts.GenerateCompileScriptHandler",

CommandContributionItem.STYLE_PUSH);
CommandContributionItem commandContributionItem = new
CommandContributionItem(commandContributionItemParameter);
iContributionRoot.addContributionItem(commandContributionItem, null);

int tempDebug = 0;
}// try
catch (Exception e)
{
@SuppressWarnings("unused")
int tempDebug2 = 1;
}// catch (Exception e)
}// public void createContributionItems(IServiceLocator
iServiceLocator, IContributionRoot iContributionRoot)



On 2/24/2012 10:22 AM, Charlie Kelly wrote:
> Hi,
>
> How can I filter a menu contribution for popup menus so that it only
> appears when a project contains a particular project nature?
>
> Thanks
>
> Charlie
Previous Topic:Erico
Next Topic:Eclipse IDE for EGL Web developers
Goto Forum:
  


Current Time: Fri Apr 19 10:04:09 GMT 2024

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

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

Back to the top