Where is addStdResource in Maia?

I'm trying to load an xml schema file. I used to use this code for it:
ExternalResourceManager.getInstance().addStdResource(namespace, filename, getClass());
But now IDEA doesn't recognize addStdResource - only addResource.
What should I do?

11 comments
Comment actions Permalink

use extension point <standardResourceProvider>

then register like this

    registrar.addStdResource(uri, localPath, OneOfYourApplicationComponent.class);


HTH,
Yann

0
Comment actions Permalink

Ok, great but what do I do with the standardResourceProvider? Do I have to register it somewhere because registerResources is never called.
I put the code in the initComponent of my main ApplicationComponent class. Maybe that's too late or something?

 public void initComponent() {
        standardResourceProvider = new StandardResourceProvider() {
            public void registerResources(ResourceRegistrar resourceRegistrar) {
                System.out.println("registering resource");
                resourceRegistrar.addStdResource("http://www.bindows.net/Schema/3.0/", "BindowsAdfSchema.xsd", MiniLauncherComponent.class);
            }
        };
 }

0
Comment actions Permalink

you must use and declare it as extensionpoint in your plugin.xml:

<extensions defaultExtensionNs="com.intellij">

    <standardResourceProvider implementation="com.something.YourResourceProvider"/>


</extension>

0
Comment actions Permalink

It's still not getting called. This is the entire contents of my plugin.xml:

<idea-plugin version="2">
  <name>Plugin name here</name>
  <description>short description of the plugin</description>
  <version>1.0</version>
  <vendor>YourCompany</vendor>
  <idea-version since-build="8000"/>

  <application-components>
    <!-- Add your application components here -->
  </application-components>

  <project-components>
    <!-- Add your project components here -->
  </project-components>

  <actions>
    <!-- Add your actions here -->
  </actions>

  <extensions defaultExtensionNs="com.intellij">
     <standardResourceProvider implementation="com.segerfeldt.minilauncher.schemas.SchemaResources"/>
  </extensions>
</idea-plugin>



And I made a very simple class that just implements the interface.

public class SchemaResources implements StandardResourceProvider {
    public void registerResources(ResourceRegistrar resourceRegistrar) {
        System.out.println("res prov");
        resourceRegistrar.addStdResource("http://www.bindows.net/Schema/3.0/", "BindowsAdfSchema.xsd", MiniLauncherComponent.class);
    }
}


I'm not getting the system.out message. No error messages. What could be wrong?
0
Comment actions Permalink

<extensions> must be before <application-components>

please verify your order against other plugin.xml files

0
Comment actions Permalink

I moved the extensions tag above it but that didn't help either.
I have plowed through all plugin.xml files in the IDEA 8 dev package (there seem to be no dev package for Maia) but not a single one uses the standardResourceProvider tag.

Another thing: when using this dtd: <!DOCTYPE idea-plugin PUBLIC "Plugin/DTD" "http://plugins.intellij.net/plugin.dtd">
IDEA complain that "Element type standardResourceProvider must be declared". Might not be important but I'm grasping at straws here.

0
Comment actions Permalink

I have found out that if I create a new plugin from scratch with just an ApplicationComponent and a class that implements StandardResourceProvider it works.
Unless I set the -Xmx1024m switch though IntelliJ is acting really flaky (I wonder if this has anything to do with me being on snow leopard). My problem now is that nothing of this works in my real plugin and I don't have a clue what breaks it.
Anyone feel like taking a look at my plugin?

Btw: When creating a new plugin the auto generated plugin.xml has the extensions section at the bottom. Don't know if it really matters yet though as I always move it to the top as per your recommendation.

0
Comment actions Permalink

check your plugin module's settings, most probably the path to the plugin.xml to use is broken

-Xmx256m should be enough to start your plugin

0
Comment actions Permalink

You are absolutely right! I had multiple plugin.xml files even without noticing it. IntelliJ generates them when you change that path in the modules settings. I was even editing the wrong plugin.xml. Thanks a lot for you help so far.

Now I reach the code that does the actual registration of the xml schema file but unfortunately it does not seem to load because the schema is not available in code completion later on. This is my code:

    public void registerResources(ResourceRegistrar resourceRegistrar) {
        System.out.println("minilauncher register resources");
        resourceRegistrar.addStdResource("http://www.bindows.net/Schema/3.0/", "BindowsAdfSchema.xsd", MiniLauncherComponent.class);
    }

I do get the println in the console so thats good. The BindowsAdfSchema.xsd file is located in the same dir/package as the SchemaResources class itself (but MinLauncherComponent is in a different package). In the idea.log I can see that it couldnt find the resource:

pl.ExternalResourceManagerImpl - Cannot find standard resource. filename:BindowsAdfSchema.xsd klass=class com.segerfeldt.minilauncher.schemas.SchemaResources

How should I reference the file correctly to get it to load.

0
Comment actions Permalink

You must use FQN classpath resource notation, e.g. "/com/package/schema.xsd" where schema.xsd is located in this package

0
Comment actions Permalink

It wooorks!

For anyone else reading this, don't forget to add ;?*.xsd in the compiler settings or the xsd file won't be outputted to the jar.
I had done this but it took me half an hour to figure out that I had neglected the semicolon in there. Anyway, it works now.

Thanks a lot for you help Yann.

0

Please sign in to leave a comment.