Published: 08/29/11 11:31 PM
It’s sometimes kinda hard to force your Netbeans RCP Standalone Application to open the Favorites Window per Default (at least when using maven).
Here’s the solution:
The easiest way to start is to open your layer.xml-file in the explorer view (by using the plus-sign, don’t open it in the editor). Search the folder <this layer in context> and search for the Windows2-folder. Open it. You should see a favorites.wstcref entry. Double click.
change <state opened=”false” /> to <state opened=”true” />.
Make sure to specify a module tag (see below on how to get this right)..
Netbeans created an entry in the layer-file for you that should look like this:
<folder name="explorer"> <file name="favorites.wstcref" url="favoritesWstcref.xml"/> </folder>
If it didn’t, create that entry on your own now.
Here’s some context-info, just place that section anywhere directly under the filesystem-tag:
<folder name="Windows2"> <folder name="Modes"> <folder name="explorer"> <file name="favorites.wstcref" url="favoritesWstcref.xml"/> </folder> </folder> </folder>
Netbeans also created a file named “favoritesWstcref.xml” for you under src/main/resources/path.to.your.package. The name doesn’t matter, just make sure to have the same name as referenced by the url-attribute of the file-tag in the layer.xml (see above).
The file should look like this (although Netbeans might not have created the very important module-tag. Just make sure to have everything just like below in the favoritesWstcref.xml-file):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd"> <tc-ref version="2.2"> <module name="org.netbeans.modules.favorites/1" spec="1.25.1"/> <tc-id id="favorites" /> <state opened="true" /> </tc-ref>
You’ll wonder which settings to take (especially when you don’t use Netbeans RCP Release701 as I did here).
You can look that up in the dependency which you will define right now.
You need to define a Dependency to the Favorites module in order to make sure that it gets loaded before your module, otherwise you’ll have a Favorites-Window that disappears under certain circumstances on startup or won’t show up at all.
To define the dependency you might want to search by right-clicking the “Dependencies”-Folder and choose “Add Dependency…” enter “favorites” in the Query-Input-Field and choose the appropriate module and version (in my case “org.netbeans.modules : org-netbeans-modules-favorites” RELEASE701 [nbm] – netbeans)
Or you could simply add it to your pom.xml under dependencies like this:
<dependency> <groupId>org.netbeans.modules</groupId> <artifactId>org-netbeans-modules-favorites</artifactId> <version>RELEASE701</version> </dependency>
Once downloaded have a look at Dependencies/org-netbeans-modules-favorites-RELEASE701.jar or whatever version you chose in the explorer-window of netbeans. Open META-INF/MANIFEST.MF to get the infos you need for the above mentioned module-tag in the favoritesWstcref.xml-file.
The important entries are:
OPENIDE-Module: org.netbeans.modules.favorites/1
and
OpenIDE-Module-Specification-Version: 1.25.1
These two values are needed for the attributes of the modules-tag in the favoritesWstcref.xml-file.
When you build your project, you will get an error-message saying:
“Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:3.5:manifest (default-manifest) on project [...]: Module dependency has friend dependency on org.netbeans.modules.favoritesbut is not listed as friend. -> [Help 1]”
This means that you have to specify an implementation version of the favorites-module (which is pretty bad, because your module will only work with this very version afterwards). You can specify that you wish to use the implemenation version by modifying src/main/nbm/module.xml to contain the following entry:
<dependencies> <dependency> <id>org.netbeans.modules:org-netbeans-modules-favorites</id> <type>impl</type> <explicitValue>org.netbeans.modules.favorites/1 = 201107282000</explicitValue> </dependency> </dependencies>
Again, have a look at the Dependencies/org-netbeans-modules-favorites-RELEASE701.jar /META-INF/MANIFEST.MF to find the right values for explicitValue:
the important values are:
OpenIDE-Module: org.netbeans.modules.favorites/1
and
OpenIDE-Module-Implementation-Version: 201107282000
If you get an error like the one below at runtime (open View/IDELog, when parts of your applications GUI or functionality are missing on startup, you’ll find the errors there (just be patient, they’ll appear in a minute)), then you’ve got a typo in your module.xml.
WARNING [org.netbeans.core.startup.ModuleList]: Error encountered while reading [YOUR_MODULE] java.lang.IllegalArgumentException: Malformed dot-separated identifier: [YOUR_EXPLICIT_VALUE_IN_MODULES.XML] at org.openide.modules.Dependency.checkCodeName(Dependency.java:201) at org.openide.modules.Dependency.create(Dependency.java:275) at org.netbeans.Module.initDeps(Module.java:683) at org.netbeans.Module.parseManifest(Module.java:465) Caused: org.netbeans.InvalidException: While parsing [YOUR_PACKAGE] a dependency attribute at org.netbeans.Module.parseManifest(Module.java:467) at org.netbeans.StandardModule.(StandardModule.java:136) at org.netbeans.ModuleFactory.create(ModuleFactory.java:69) at org.netbeans.ModuleManager.create(ModuleManager.java:594) [catch] at org.netbeans.core.startup.ModuleList$ReadInitial.run(ModuleList.java:1611) at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:125) at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:566) at org.netbeans.core.startup.ModuleList.readInitial(ModuleList.java:168) at org.netbeans.core.startup.ModuleSystem.readList(ModuleSystem.java:280) at org.netbeans.core.startup.Main.getModuleSystem(Main.java:171) at org.netbeans.core.startup.Main.start(Main.java:308) at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123) at java.lang.Thread.run(Thread.java:722)
I found the following links helpful: