--- a/options.api/apichanges.xml +++ a/options.api/apichanges.xml @@ -75,6 +75,19 @@ + + + API to control whether the options window should be modal or not when opened + + + + + + Added API to control whether the options window should be modal or not when opened. + + + + API to handle successfull search in some panel in options window --- a/options.api/manifest.mf +++ a/options.api/manifest.mf @@ -2,6 +2,6 @@ OpenIDE-Module: org.netbeans.modules.options.api/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/options/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/options/resources/mf-layer.xml -OpenIDE-Module-Specification-Version: 1.32 +OpenIDE-Module-Specification-Version: 1.33 AutoUpdate-Show-In-Client: false AutoUpdate-Essential-Module: true --- a/options.api/src/org/netbeans/api/options/OptionsDisplayer.java +++ a/options.api/src/org/netbeans/api/options/OptionsDisplayer.java @@ -103,7 +103,7 @@ } /** - * Open the options dialog with no guarantee which category is pre-selected. + * Open the options dialog (in non-modal mode) with no guarantee which category is pre-selected. * @return true if optins dialog was sucesfully opened with some pre-selected * category. If no category is registered at all then false will be returned and * options dialog won't be opened. @@ -134,7 +134,7 @@ } /** - * Open the options dialog with some panel preselected. + * Open the options dialog (in non-modal mode) with some panel preselected. * To open a top-level panel, pass its {@link TopLevelRegistration#id}. * To open a subpanel, pass its {@link SubRegistration#location} followed by {@code /} * followed by its {@link SubRegistration#id}. @@ -182,6 +182,46 @@ } } + /** + * Open the options dialog with no guarantee which category is pre-selected. + * @param isModal true if the options window should be in modal mode, false otherwise + * @return true if options dialog was successfully opened with some pre-selected + * category. If no category is registered at all then false will be returned and + * options dialog won't be opened. + * @since 1.33 + */ + public boolean open(boolean isModal) { + impl.setIsModal(isModal); + return open(); + } + + /** + * Open the options dialog with some panel preselected. + * To open a top-level panel, pass its {@link TopLevelRegistration#id}. + * To open a subpanel, pass its {@link SubRegistration#location} followed by {@code /} + * followed by its {@link SubRegistration#id}. + * To open a container panel without specifying a particular subpanel, pass its {@link ContainerRegistration#id}. + * To avoid typos and keep track of dependencies it is recommended to define compile-time + * constants for all these IDs, to be used both by the annotations and by calls to this method. + * @param path slash-separated path of category and perhaps subcategories to be selected + * @param isModal true if the options window should be in modal mode, false otherwise + * @return true if options dialog was successfully opened with required category. + * If this method is called when options dialog is already opened then this method + * will return immediately false without affecting currently selected category + * in opened options dialog. + * If category (i.e. the first item in the path) does not correspond to any + * of registered categories then false is returned and options dialog is not opened + * at all (e.g. in case that module providing such category is not installed or enabled). + * If subcategory doesn't exist, it opens with category selected and + * it returns true. It is up to particular OptionsPanelController + * to handle such situation. + * @since 1.33 + */ + public boolean open(String path, boolean isModal) { + impl.setIsModal(isModal); + return open(path); + } + private boolean openImpl(final String path) { if(path == null) { log.warning("Category to open is null."); //NOI18N --- a/options.api/src/org/netbeans/modules/options/OptionsDisplayerImpl.java +++ a/options.api/src/org/netbeans/modules/options/OptionsDisplayerImpl.java @@ -127,6 +127,10 @@ Exceptions.printStackTrace(ex); } } + + public void setIsModal(boolean isModal) { + this.modal = isModal; + } public boolean isOpen() { return dialog != null; --- a/options.api/test/unit/src/org/netbeans/api/options/OptionsDisplayerOpenTest.java +++ a/options.api/test/unit/src/org/netbeans/api/options/OptionsDisplayerOpenTest.java @@ -279,6 +279,24 @@ } } } + + public void testModality() throws Exception { + OptionsDisplayer.getDefault().open(false) ; + modality(displayer.descriptor, false); + close(); + + TestDisplayer td = new TestDisplayer(); + td.createDialog(new DialogDescriptor(displayer, null, true, null)); + OptionsDisplayer.getDefault().open(true) ; + modality(td.descriptor, true); + close(); + } + + public void modality(DialogDescriptor desc, boolean expectedResult) { + if (desc != null) { + assertEquals(expectedResult, desc.isModal()); + } + } public void open(boolean expectedResult) { modality(displayer.descriptor);