ExportImportOptions

Revision as of 15:21, 10 December 2013 by Mkleint (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Export/Import Options in NetBeans - Proposal

This is a proposal document about implementation of very desired feature - Export/Import of user's settings/options in NetBeans. This feature has already been implemented and is documented as OptionsExport layer API.

Contents


Motivation

There is a lot of duplicates of highly voted Issue 42157. Our users want to share options with workmates, backup options and easily transfer options between NetBeans releases. Read the following complain copied from the issue:

"The biggest thing for me is when moving from 5.x to 6.x betas, for example, I have to reconfigure all my settings. That's bad enough, but worse, when moving from 6.x beta 1 to beta 2, I have to reconfigure the settings again, and when moving to 6.x final, I have to reconfigure the settings AGAIN!"


Current state

At the time it is only supported to import options at the very first start of newly installed newer version of NetBeans. If older userdir exists at expected location (for example ${home}/.netbeans/6.1, user is offered to import previous options. If confirmed, previous userdir's content is copied to the current userdir according to includes/excludes patterns summarized in NB65SettingsMigration.

  • Advantages
  • centralized control over import
  • doesn't need restart
  • impossible clashes between versions
  • Disadvantages
  • user cannot choose arbitrary version or userdir
  • import possible only once
  • need input from module developers what to import (every release)
  • export/import on demand not possible

Solution

In the NetBeans user interface there should be an explicit action for export and import of options. The export action shows a dialog with options available for export. User selects desired items, chooses output target (probably a zip file) and finishes the export. Vice versa, the import action allows user to browse for input source (zip file or may be userdir). Then it shows a dialog with options available for import, user selects items and finishes the import. Restart of the IDE causes imported options to take effect. On the contrary to the current solution advantages and disadvantages are almost inverse but advantages prevail.

  • Advantages
  • user can import from arbitrary version/userdir
  • export/import possible repeatedly
  • module developers have full control over import/export (not centralized)
  • user can export/import selectively
  • Disadvantages
  • needs restart (in most cases)
  • need to avoid clashes between versions and with existing options

Implementation details

To support suggested solution we need some implementation background. The idea is to register patterns for export/import into module's layer. This solution is necessary because of so called ergonomics IDE. On the first start only minimal subset of modules is enabled. So, we would not be able to collect import patterns from all modules. But we can prepare list of all patterns at the build time. Then the upgrader module can use this list and import settings before IDE starts. Ad-hoc export/import action doesn't need such list because it can read registrations for all enabled modules at runtime. Selected files are then copied from source userdir into target userdir (zip file). Export/import actions and other related stuff will be part of the options.api module.

Module developers will make a registration in module's layer. Import/export occurs according to given include/exclude patterns. But only if there is some file in current userdir matching given patterns, the item is displayed in the Export dialog. Patterns are relative to userdir root.

<folder name="OptionsExport">
    <!-- category -->
    <folder name="Arbitrary">
        <!-- position of Arbitrary folder relative to other items -->
        <attr name="position" intvalue="666"/>
        <!-- category display name -->
        <attr name="displayName"
          bundlevalue="org.netbeans.modules.arbitrary.options.Bundle#Category_Display_Name"/>
        <!-- item -->
        <file name="arbOpt">
            <attr name="include"
              stringvalue="config/Preferences/org/netbeans/modules/arbitrary/.*|var/arbitrary/.*"/>
            <attr name="exclude" stringvalue="config/Preferences/org/netbeans/modules/obsolete/.*"/>
            <attr name="displayName"
              bundlevalue="org.netbeans.modules.arbitrary.options.Bundle#Export_Display_Name"/>
        </file>
    </folder>
</folder>
If the include pattern contains this group token
"([^/]*)"
, all found groups (sub folders) are detected and offered as individual items in list of available options. It can be used for example for keymap profiles.
            <attr name="include" stringvalue="config/Keymaps/([^/]*)/.*"/>

Use cases

1) Export Options to zip

  • user invokes Export action from Options dialog
  • dialog with all options available for export is opened
  • user selects some options
  • user has to choose target folder
  • all patterns of selected items are collected and resulting files from the current userdir are packed into a zip file in target folder

2) Import Options from zip or folder

  • user invokes Import action from Options dialog
  • user has to choose source folder or source zip file
  • dialog with all options available for import is opened
  • user selects some options
  • all patterns of selected items are collected and resulting files are copied from source to the current userdir. Existing files are overwritten. There should be no problem importing from older or newer versions. Obsolete or brand new options should be ignored because patterns in the current IDE match only known options/files.
  • restart is recommended but user can to postpone it

3) Import Options after new installation

  • on the first start, before the Main window is up, detect previous userdir in ${home}/.netbeans
  • dialog asking whether to import options is opened
  • if confirmed, all files from previous userdir, which match list of all modules patterns, are copied from previous userdir to the current one

Problems/TODO

Keymap profiles

At the time there exist default keymap profiles which are not stored in userdir. If user changes default profile, only the difference is stored to userdir. Cloned profile is stored to userdir complete. To export/import a profile user can use Tools>Options>Keymap>Manage Profiles dialog. It stores/reads profile to/from xml file. It doesn't allow to overwrite existing profiles.

With suggested export/import facility only diffs stored in userdir can be transfered for default profiles and then they are merged with existing default profiles. It can cause conflicts between shortcuts or cause problems if storage format changes. But the same problem with format is with xml file.

The solution would be to make default profiles read-only and allow user to duplicate default profile and make changes on that copy. Then all user profiles are stored in userdir and it is possible transfer them from userdir to userdir.

UI proposal

Export/Import actions are accessible from the Options dialog.

Image:options-dialog_ExportImportOptions.png
\
\

User must select target zip file for exported files and select some items from available options.

Image:export02_ExportImportOptions.png
\
\

For import user can choose whether import from arbitrary userdir or previously created zip file.

Image:import02_ExportImportOptions.png
\
\

Restart after import is highly recommended because imported options need to replace old ones in memory.

Image:restart1_ExportImportOptions.png
\
\

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo