Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » PropertyTester: Want to determine does my Project have my custom nature
PropertyTester: Want to determine does my Project have my custom nature [message #882964] Thu, 07 June 2012 10:37 Go to next message
Marjan Stojanovic is currently offline Marjan Stojanovic
Messages: 6
Registered: June 2012
Junior Member
I have problem from restricting my label to be visible when i select some project in project explorer. I want it to be visible only when selected project doesnt have my custom nature using Property Tester (if u know some other, easier way im open for new solutions).

This is my property Tester extension point:

<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="plugin.plugintests.ProjectNatureTester"
id="plugin.plugintests.natureTester"
namespace="my.plugintests"
properties="changeNature"
type="org.eclipse.core.resources.IResource">
</propertyTester>
</extension>

and this is how i use it:

<visibleWhen
checkEnabled="false">
<with
variable="activeMenuSelection">
<iterate
ifEmpty="false"
operator="or">
<test
property="my.plugintests.changeNature">
</test>

</iterate>
</with>
</visibleWhen>


***********************************************
*********************************************** Class implementation
***********************************************
protected static final String PROJECT_NATURE = "changeNature";

public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
// TODO Auto-generated method stub
System.out.println("Usao sam u test");
boolean temp;
if (!(receiver instanceof IResource)) {
temp = false;
System.out.println("Prvi IF: " + temp);
return temp;
}
if (property.equals(PROJECT_NATURE)) {
final IProject proj = (IProject) receiver;
try {
temp = proj != null && proj.isAccessible() && proj.hasNature(toString(expectedValue));
System.out.println("Drugi IF: " + temp);
return temp;
} catch (final CoreException e) {
temp = false;
System.out.println("Catch: " + temp);
return temp;
}
}
System.out.println("Krajnji return false");
return false;
}

The problem is also that i dont have any messages printed in my console... I also tryed with forcePluginActivation but it didnt help. Also tryed:

<test
property = "org.eclipse.core.resources.projectNature"
value = "id of my custom nature"
</test>
but it didnt want also to work.
Re: PropertyTester: Want to determine does my Project have my custom nature [message #883454 is a reply to message #882964] Fri, 08 June 2012 11:09 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What kind of project were you selecting? Was it in the Package Explorer?

PW


Re: PropertyTester: Want to determine does my Project have my custom nature [message #885524 is a reply to message #883454] Wed, 13 June 2012 03:18 Go to previous messageGo to next message
Marjan Stojanovic is currently offline Marjan Stojanovic
Messages: 6
Registered: June 2012
Junior Member
yes, its in package explorer
Re: PropertyTester: Want to determine does my Project have my custom nature [message #885679 is a reply to message #885524] Wed, 13 June 2012 08:34 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

There is a property tester already available to test project natures, see http://wiki.eclipse.org/Command_Core_Expressions#Property_Testers

But even in your case, java projects would be IJavaProjects, not IResources. Try using something like:

<with variable="activeMenuSelection">
  <iterate ifEmpty="false">
    <adapt type="org.eclipse.core.resources.IResource">
      <test ..../>
    </adapt>
  </iterate>
</with>


PW


Re: PropertyTester: Want to determine does my Project have my custom nature [message #892413 is a reply to message #882964] Thu, 28 June 2012 03:36 Go to previous message
Marjan Stojanovic is currently offline Marjan Stojanovic
Messages: 6
Registered: June 2012
Junior Member
thank you paul, although i saw that wiki a months ago i didnt realise till now how it does functioning Smile
it finished job! Smile
Previous Topic:Writing autocomplete components for Eclipse
Next Topic:Where is the Eclipse 4.2/3.8 Platform SDK download?
Goto Forum:
  


Current Time: Tue Jul 29 14:54:52 EDT 2014

Powered by FUDForum. Page generated in 0.01603 seconds