Preferences System Migration
This guide lists the actions necessary in order to migrate the preferences system from BEAM to SNAP
Step-by-step guide for creating a primary panel
Plug into NetBeans Preferences Dialog and extend it with a primary panel. See here for a tutorial. Anyway, the necessary actions are:
- In the module
snap-gui
, create a controller class extendingOptionsPanelController
- Annotate the class with
OptionsPanelController.TopLevelRegistration
andorg.openide.util.NbBundle.Messages
annotations. - Create a class which extends or wraps
JComponent
. According to the tutorial, it makes sense to create the methodsload()
,store()
, andvalid()
, as described in the tutorial. - Implement the abstract methods in the controller class, call the
load()
,store()
,valid()
-methods appropriatly - Be sure to have a dependency on the artifact
org-netbeans-modules-options-api
in the grouporg.netbeans.api
- Maybe you need to do a clean of the
snap-gui
-module in order to see the extensions in the GUI. - In order to store the user preference
somePreference
which the user edits in the componentsomeTextField
, add a line similar toNbPreferences.forModule(YourPanel.class).put("somePreference", someTextField.getText())
to thestore()
-method - Add a line similar to
someTextField.setText(NbPreferences.forModule(YourPanel.class).get("somePreference", "")
to theload()
-method in order to load the user preferencesomePreference
.
Step-by-step guide for creating a secondary panel
Plug into NetBeans Preferences Dialog and extend it with a secondary panel. See here for a tutorial. Anyway, the necessary actions are:
- In the module
snap-gui
, create a new package, and a filepackage-info.java
- Within that file, annotate the package with
OptionsPanelController.ContainerRegistration
- Create a class within the package that extends
OptionsPanelController
- Annotate it with
OptionsPanelController.SubRegistration
- As value for the annotation field
location
use the id you set in step 2. - Do steps 4-8 of the previous section accordingly
Troubleshooting
If your code does not compile due to a Bundle.properties not found
error: remove the annotations, compile again, put the annotations in again.
Be sure to add the org.openide.util.NbBundle.Messages
annotation, especially when you are creating a secondary panel. This is not mentioned in the tutorial!
After adding a new panel, you'll need to do a mvn clean package
. Make is not sufficient, nor is an easy package; clean is mandatory.
Be sure that you don't have duplicate display names; see http://stackoverflow.com/q/27376939/2043113.