SDK plugin dev’s document got errors…

I follow plugin dev’s document and found some mistakes:



[java]private final Result<JmeSpatial> result;



//method to register the listener;

private void registerListener(){

result = Utilities.actionsGlobalContext().lookupResult(JmeSpatial.class);

result.addLookupListener(this);

}



//implements org.openide.util.LookupListener (called from AWT thread)

public void resultChanged(LookupEvent ev) {

Collection<JmeSpatial> items = (Collection<JmeSpatial>) result.allInstances();

for (JmeSpatial jmeSpatial : items) {

//Using the JmeSpatials properties you can modify the spatial directly from the AWT thread:

spatial.getPropertySets()[0].setValue(“Local Translation”, Vector3f.ZERO);

return;

}

}[/java]



Is it “jmeSpatial” or “spatial” ???



Then I got some strange errors like these , how can I solve them??



http://i.imgur.com/BVkbb.jpg

Its “JmeSpatial”. You forgot to add “jMonkeyPlatform Core” as one of your dependencies to the Project and thus have no access to the jMP API. Read the section on setting up jMP for plugin development.

I understand that I have to put 3 module dependencies in :



jMonkeyPlatform Core

jMonkeyPlatform Core Libraries

jMonkeyPlatform Core JME



and I had them in place (so this isn’t a import error)



this error is caused by a different reason…?

Maybe you imported the wrong Result or Collections class?

[java]package org.MyTool.AnimationControlTool;



import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;

import com.jme3.math.Vector3f;

import java.util.Collection;

import org.openide.util.LookupEvent;

import org.openide.util.NbBundle;

import org.openide.windows.TopComponent;

import org.netbeans.api.settings.ConvertAsProperties;

import org.openide.awt.ActionID;

import org.openide.awt.ActionReference;

import org.openide.util.Lookup.Result;

import org.openide.util.Utilities;[/java]



I think I’ve done the import right … :stuck_out_tongue: This error make me confused a lot and then I have a very weird April Fool ← Hey, but I’m serious for the case ! :stuck_out_tongue:



What else can we inspect ?

No Idea, the code works fine for me, its constantly used like this, e.g. in the SceneExplorer.

I know 'cause I got the old version (not follow this method) work in alpha3 … :smiley:



Ahh, there is another infos that can make you have some clue to guess :

I’m developing the plugin inside JMP alpha4 itself…



in SceneExplorer.java

[java]

private final Result<AbstractSceneExplorerNode> nodeSelectionResult;

private AbstractSceneExplorerNode selectedSpatial;





public void resultChanged(LookupEvent ev) {

Collection collection = nodeSelectionResult.allInstances();

for (Iterator it = collection.iterator(); it.hasNext():wink: {

Object object = it.next();

if (object instanceof AbstractSceneExplorerNode) {

selectedSpatial = (AbstractSceneExplorerNode) object;

return;

}

}

selectedSpatial = null;

}



[/java]



so the Collection is of AbstractSceneExplorerNode not a JmeSpartial (hovewer JmeSpartial extends AbstractSceneExplorerNode )???

Yes, I changed that code to JmeSpatial to test it, works just as well. Everything is correct.

Maybe you have to add the “Lookup API” too if you didn’t already. Just search for the classes that have problems in the Library manager when you add a library. It will show you what library sets these are in, then just add them.

Got it work…!



What a silly mistake : I didn’t add the Nodes API …

← This cause the compiler can not see what JmeSpartial extends from … maybe!



Ahh, I think it’s not necessary to say that but you guy should correct the doc and add some more step by step introductions for the plugin dev for the new comer… thought !



Wish you a nice day !