diff -r 81c86e07c313 options.api/apichanges.xml --- a/options.api/apichanges.xml Thu May 15 05:30:07 2008 +0200 +++ b/options.api/apichanges.xml Thu May 15 13:07:20 2008 +0200 @@ -72,6 +72,19 @@ + + + API to open the options dialog with some subcategory pre-selected + + + + + + Added API to open the options dialog with some subcategory pre-selected. + + + + API to open the options dialog with some category pre-selected diff -r 81c86e07c313 options.api/manifest.mf --- a/options.api/manifest.mf Thu May 15 05:30:07 2008 +0200 +++ b/options.api/manifest.mf Thu May 15 13:07:20 2008 +0200 @@ -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.7 +OpenIDE-Module-Specification-Version: 1.8 AutoUpdate-Show-In-Client: false AutoUpdate-Essential-Module: true diff -r 81c86e07c313 options.api/src/org/netbeans/api/options/OptionsDisplayer.java --- a/options.api/src/org/netbeans/api/options/OptionsDisplayer.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/api/options/OptionsDisplayer.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -95,10 +95,36 @@ */ public boolean open(final String categoryId) { log.fine("Open Options Dialog: " + categoryId); //NOI18N - return openImpl(categoryId); + return openImpl(categoryId, null); } - private boolean openImpl(final String categoryId) { + /** + * Open the options dialog with some category and its subcategory pre-selected. + * @param categoryId ID representing required category which is registration name + * (e.g. "FooOptionsPanelID" for following registration: + *
+     * <folder name="OptionsDialog">
+     *     <file name="FooOptionsPanelID">
+     *         <file name="SubFooOptionsPanelID.instance">
+     *             <attr name="instanceClass" stringvalue="org.foo.SubFooOptionsPanel"/>
+     *         </file>
+     *     </file>
+     * </folder>
+ * @param subcategoryId ID representing required subcategory (e.g. SubFooOptionsPanelID). + * @return true if optins dialog was sucesfully opened with required category and subcategory pre-selected. + * 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 categoryId passed as a parameter 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). + */ + public boolean open(final String categoryId, final String subcategoryId) { + log.fine("Open Options Dialog: " + categoryId + " subcategory: " + subcategoryId); //NOI18N + return openImpl(categoryId, subcategoryId); + } + + private boolean openImpl(final String categoryId, final String subcategoryId) { Boolean retval = Mutex.EVENT.readAccess(new Mutex.Action () { public Boolean run() { Boolean r = impl.isOpen(); @@ -112,7 +138,7 @@ log.warning("Options Dialog is opened"); //NOI18N } if (retvalForRun) { - impl.showOptionsDialog(categoryId); + impl.showOptionsDialog(categoryId, subcategoryId); } return Boolean.valueOf(retvalForRun); } diff -r 81c86e07c313 options.api/src/org/netbeans/modules/options/CategoryModel.java --- a/options.api/src/org/netbeans/modules/options/CategoryModel.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/CategoryModel.java Thu May 15 13:07:20 2008 +0200 @@ -328,6 +328,10 @@ setCurrentCategoryID(getID()); } + public void setCurrentSubcategory(String subcategoryID) { + create().setCurrentSubcategory(subcategoryID); + } + private void setHighlited(boolean highlited) { if (highlited) { highlitedCategoryID = getID(); diff -r 81c86e07c313 options.api/src/org/netbeans/modules/options/OptionsDisplayerImpl.java --- a/options.api/src/org/netbeans/modules/options/OptionsDisplayerImpl.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/OptionsDisplayerImpl.java Thu May 15 13:07:20 2008 +0200 @@ -93,7 +93,7 @@ return dialog != null; } - public void showOptionsDialog (String categoryID) { + public void showOptionsDialog (String categoryID, String subcategoryID) { if (isOpen()) { // dialog already opened dialog.setVisible (true); @@ -137,7 +137,7 @@ } dialog = DialogDisplayer.getDefault ().createDialog (descriptor); - optionsPanel.initCurrentCategory(categoryID); + optionsPanel.initCurrentCategory(categoryID, subcategoryID); dialog.addWindowListener (new MyWindowListener (optionsPanel)); dialog.setVisible (true); } diff -r 81c86e07c313 options.api/src/org/netbeans/modules/options/OptionsPanel.java --- a/options.api/src/org/netbeans/modules/options/OptionsPanel.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/OptionsPanel.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -119,13 +119,13 @@ private String getCategoryID(String categoryID) { return categoryID == null ? CategoryModel.getInstance().getCurrentCategoryID() : categoryID; } - - void initCurrentCategory (final String categoryID) { + + void initCurrentCategory (final String categoryID, final String subcategoryID) { //generalpanel should be moved to core/options and then could be implemented better //generalpanel doesn't need lookup boolean isGeneralPanel = "General".equals(getCategoryID(categoryID));//NOI18N if (CategoryModel.getInstance().isLookupInitialized() || isGeneralPanel) { - setCurrentCategory(CategoryModel.getInstance().getCategory(getCategoryID(categoryID))); + setCurrentCategory(CategoryModel.getInstance().getCategory(getCategoryID(categoryID)), subcategoryID); initActions(); } else { RequestProcessor.getDefault().post(new Runnable() { @@ -141,7 +141,7 @@ final Cursor cursor = frame.getCursor(); frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - setCurrentCategory(CategoryModel.getInstance().getCategory(getCategoryID(categoryID))); + setCurrentCategory(CategoryModel.getInstance().getCategory(getCategoryID(categoryID)), subcategoryID); initActions(); // reset cursor frame.setCursor(cursor); @@ -153,7 +153,7 @@ } } - private void setCurrentCategory (final CategoryModel.Category category) { + private void setCurrentCategory (final CategoryModel.Category category, String subcategoryID) { CategoryModel.Category oldCategory = CategoryModel.getInstance().getCurrent(); if (oldCategory != null) { (buttons.get(oldCategory.getID())).setNormal (); @@ -162,7 +162,7 @@ (buttons.get(category.getID())).setSelected (); } - CategoryModel.getInstance().setCurrent(category); + CategoryModel.getInstance().setCurrent(category); JComponent component = category.getComponent(); category.update(controllerListener, false); final Dimension size = component.getSize(); @@ -175,6 +175,9 @@ ((CategoryButton) buttons.get (CategoryModel.getInstance().getCurrentCategoryID())).requestFocus(); } */ firePropertyChange ("buran" + OptionsPanelController.PROP_HELP_CTX, null, null); + if(subcategoryID != null) { + category.setCurrentSubcategory(subcategoryID); + } } HelpCtx getHelpCtx () { @@ -382,7 +385,7 @@ this.category = category; } public void actionPerformed (ActionEvent e) { - setCurrentCategory (category); + setCurrentCategory (category, null); } } @@ -390,20 +393,20 @@ public void actionPerformed(ActionEvent e) { CategoryModel.Category highlightedB = CategoryModel.getInstance().getCategory(CategoryModel.getInstance().getHighlitedCategoryID()); if (highlightedB != null) { - setCurrentCategory(highlightedB); + setCurrentCategory(highlightedB, null); } } } private class PreviousAction extends AbstractAction { public void actionPerformed (ActionEvent e) { - setCurrentCategory (CategoryModel.getInstance().getPreviousCategory()); + setCurrentCategory (CategoryModel.getInstance().getPreviousCategory(), null); } } private class NextAction extends AbstractAction { public void actionPerformed (ActionEvent e) { - setCurrentCategory (CategoryModel.getInstance().getNextCategory()); + setCurrentCategory (CategoryModel.getInstance().getNextCategory(), null); } } @@ -498,7 +501,7 @@ public void mouseReleased (MouseEvent e) { if (!category.isCurrent() && category.isHighlited() && CategoryModel.getInstance().getCurrent() != null) { - setCurrentCategory(category); + setCurrentCategory(category, null); } } diff -r 81c86e07c313 options.api/src/org/netbeans/modules/options/advanced/Advanced.java --- a/options.api/src/org/netbeans/modules/options/advanced/Advanced.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/Advanced.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -57,12 +57,15 @@ */ public final class Advanced extends OptionsCategory { + private OptionsPanelController controller; + private static String loc (String key) { return NbBundle.getMessage (Advanced.class, key); } private static Icon icon; + @Override public Icon getIcon () { if (icon == null) icon = new ImageIcon ( @@ -85,6 +88,9 @@ } public OptionsPanelController create () { - return new AdvancedPanelController (); - } + if (controller == null) { + controller = new AdvancedPanelController (); + } + return controller; + } } diff -r 81c86e07c313 options.api/src/org/netbeans/modules/options/advanced/AdvancedPanel.java --- a/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanel.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanel.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -44,6 +44,7 @@ import java.awt.BorderLayout; import java.util.Iterator; import java.util.List; +import java.util.logging.Logger; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; @@ -54,7 +55,6 @@ import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; -import org.netbeans.modules.options.*; import org.openide.util.LookupEvent; import org.openide.util.LookupListener; @@ -65,7 +65,8 @@ * @author Jan Jancura */ public final class AdvancedPanel extends JPanel { - JTabbedPane tabbedPanel; + JTabbedPane tabbedPanel; + private static final Logger LOGGER = Logger.getLogger(AdvancedPanel.class.getName()); private LookupListener listener = new LookupListenerImpl(); private Model model = new Model (listener); private ChangeListener changeListener = new ChangeListener () { @@ -117,7 +118,7 @@ add (tabbedPanel, BorderLayout.CENTER); initTabbedPane (masterLookup); } - + private void initTabbedPane(Lookup masterLookup) { tabbedPanel.removeChangeListener(changeListener); tabbedPanel.removeAll(); @@ -130,6 +131,32 @@ } tabbedPanel.addChangeListener(changeListener); handleTabSwitched(); + } + + public void setCurrentSubcategory(String subcategoryID) { + LOGGER.fine("Set current subcategory: "+subcategoryID); + if(!model.getIDs().contains(subcategoryID)) { + LOGGER.warning("Subcategory "+subcategoryID+" not found."); + return; + } + String newDisplayName = model.getDisplayName(subcategoryID); + String currentDisplayName = getSelectedDisplayName(); + if (!newDisplayName.equals(currentDisplayName)) { + for (int i = 0; i < tabbedPanel.getComponentCount(); i++) { + if (tabbedPanel.getTitleAt(i).equals(newDisplayName)) { + tabbedPanel.setSelectedIndex(i); + } + } + } + } + + private String getSelectedDisplayName() { + String categoryDisplayName = null; + final int selectedIndex = tabbedPanel.getSelectedIndex(); + if (selectedIndex != -1) { + categoryDisplayName = tabbedPanel.getTitleAt(selectedIndex); + } + return categoryDisplayName; } private void handleTabSwitched() { diff -r 81c86e07c313 options.api/src/org/netbeans/modules/options/advanced/AdvancedPanelController.java --- a/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanelController.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanelController.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -85,6 +85,11 @@ return getAdvancedPanel (); } + @Override + public void setCurrentSubcategory(String subcategoryID) { + getAdvancedPanel().setCurrentSubcategory(subcategoryID); + } + public HelpCtx getHelpCtx () { return getAdvancedPanel ().getHelpCtx (); } diff -r 81c86e07c313 options.api/src/org/netbeans/modules/options/advanced/Model.java --- a/options.api/src/org/netbeans/modules/options/advanced/Model.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/Model.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -58,6 +58,7 @@ import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; +import org.openide.util.Lookup.Item; import org.openide.util.Lookup.Result; import org.openide.util.LookupListener; import org.openide.util.lookup.Lookups; @@ -69,6 +70,8 @@ */ public final class Model extends TabbedPanelModel { + private static final String ADVANCED_PATH = "OptionsDialog/Advanced"; //NOI18N + private Map idToCategory = new HashMap(); private Map categoryToOption = new HashMap(); private Map categoryToPanel = new HashMap (); private Map categoryToController = new HashMap(); @@ -88,11 +91,28 @@ return l; } + /** Returns list of IDs in this model. + * @return list of IDs in this model + */ + public List getIDs() { + init(); + return new ArrayList(idToCategory.keySet()); + } + public String getToolTip (String category) { AdvancedOption option = categoryToOption.get (category); return option.getTooltip (); } + /** Returns display name for given categoryID. + * @param categoryID ID of category as defined in layer xml + * @return display name of given category + */ + public String getDisplayName(String categoryID) { + AdvancedOption option = categoryToOption.get(idToCategory.get(categoryID)); + return option.getDisplayName(); + } + public JComponent getPanel (String category) { init (); JComponent panel = categoryToPanel.get (category); @@ -182,15 +202,14 @@ if (initialized) return; initialized = true; - Lookup lookup = Lookups.forPath("OptionsDialog/Advanced"); // NOI18N + Lookup lookup = Lookups.forPath(ADVANCED_PATH); lkpResult = lookup.lookup(new Lookup.Template(AdvancedOption.class)); lkpResult.addLookupListener(lkpListener); lkpListener = null; - Iterator it = lkpResult. - allInstances ().iterator (); - while (it.hasNext ()) { - AdvancedOption option = it.next (); - categoryToOption.put (option.getDisplayName (), option); + for(Item item : lkpResult.allItems()) { + AdvancedOption option = item.getInstance(); + categoryToOption.put(option.getDisplayName(), option); + idToCategory.put(item.getId().substring(ADVANCED_PATH.length()+1), item.getInstance().getDisplayName()); } } diff -r 81c86e07c313 options.api/src/org/netbeans/spi/options/OptionsPanelController.java --- a/options.api/src/org/netbeans/spi/options/OptionsPanelController.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/src/org/netbeans/spi/options/OptionsPanelController.java Thu May 15 13:07:20 2008 +0200 @@ -1,3 +1,43 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ package org.netbeans.spi.options; import java.beans.PropertyChangeListener; @@ -95,6 +135,13 @@ public abstract JComponent getComponent (Lookup masterLookup); /** + * Sets subcategory panel corresponding to given subcategoryID to be current. + * @param subcategoryID ID representing required subcategory + */ + public void setCurrentSubcategory(String subcategoryID) { + } + + /** * * Get current help context asociated with this panel. * diff -r 81c86e07c313 options.api/test/unit/src/org/netbeans/api/options/OptionsDisplayerOpenTest.java --- a/options.api/test/unit/src/org/netbeans/api/options/OptionsDisplayerOpenTest.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/test/unit/src/org/netbeans/api/options/OptionsDisplayerOpenTest.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -51,6 +51,7 @@ import java.awt.Dialog; import java.awt.event.ActionEvent; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; @@ -58,6 +59,9 @@ import javax.swing.JDialog; import javax.swing.SwingUtilities; import org.netbeans.junit.NbTestCase; +import org.netbeans.modules.options.advanced.Advanced; +import org.netbeans.modules.options.advanced.AdvancedPanel; +import org.netbeans.modules.options.advanced.AdvancedPanelController; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; @@ -82,7 +86,8 @@ public OptionsDisplayerOpenTest(String testName) { super(testName); } - + + @Override protected void setUp() throws Exception { log = Logger.getLogger("[Test - " + getName() + "]"); Lookup lookup = Lookups.forPath("OptionsDialog"); // NOI18N @@ -91,8 +96,10 @@ assertTrue(all.size() > 0); } + @Override protected void tearDown() throws Exception { } + /** * Test of getDefault method, of class org.netbeans.api.options.OptionsDisplayer. */ @@ -156,7 +163,47 @@ testOpenFromWorkerThread(); testOpenFromAWT(); } + + /** Test method setCurrentSubcategory is called in implementing OptionsPanelController + * when OptionsDisplayer.open(categoryId, subcategoryId) is called. + */ + public void testSubcategory() { + open("Registered", "SubcategoryID", true); + assertEquals("Subcategory not set.", "SubcategoryID", RegisteredCategory.subcategoryID); + close(); + open("Registered", null, true); + // check RegisteredCategory.create().setCurrentSubcategory not called + assertEquals("Subcategory should not be set.", "SubcategoryID", RegisteredCategory.subcategoryID); + close(); + } + public void testAdvancedSubcategory() throws Exception { + open("Advanced", null, true); + assertEquals("First subcategory should be selected by default.", Subcategory1.DISPLAY_NAME, getSelectedSubcategory()); + close(); + open("Advanced", "Subcategory2ID", true); + assertEquals("Wrong subcategory selected.", Subcategory2.DISPLAY_NAME, getSelectedSubcategory()); + close(); + open("Advanced", "UnknownID", true); + assertEquals("Wrong subcategory selected.", Subcategory2.DISPLAY_NAME, getSelectedSubcategory()); + close(); + open("Advanced", "Subcategory1ID", true); + assertEquals("Wrong subcategory selected.", Subcategory1.DISPLAY_NAME, getSelectedSubcategory()); + close(); + } + + /** Returns display name of subcategory selected in AdvancedPanel. */ + private String getSelectedSubcategory() throws Exception { + Lookup lookup = Lookups.forPath("OptionsDialog"); // NOI18N + Advanced advanced = lookup.lookup(Advanced.class); + Method getAdvancedPanelMethod = AdvancedPanelController.class.getDeclaredMethod("getAdvancedPanel", (Class[])null); + getAdvancedPanelMethod.setAccessible(true); + AdvancedPanel advancedPanel = (AdvancedPanel)getAdvancedPanelMethod.invoke(advanced.create(), (Object[])null); + Method getSelectedDisplayNameMethod = AdvancedPanel.class.getDeclaredMethod("getSelectedDisplayName", (Class[])null); + getSelectedDisplayNameMethod.setAccessible(true); + return getSelectedDisplayNameMethod.invoke(advancedPanel, (Object[])null).toString(); + } + public void openOpen(String categoryId) { for (int i = 0; i < REPEATER; i++) { if (categoryId == null) { @@ -214,7 +261,13 @@ boolean latestResult = OptionsDisplayer.getDefault().open(categoryId); assertEquals(expectedResult, latestResult); } - + + public void open(String categoryId, String subcategoryId, boolean expectedResult) { + modality(displayer.descriptor); + boolean latestResult = OptionsDisplayer.getDefault().open(categoryId, subcategoryId); + assertEquals(expectedResult, latestResult); + } + public void modality(DialogDescriptor desc) { if (desc != null) { assertFalse(desc.isModal()); @@ -231,6 +284,7 @@ displayer.close(); } + @Override protected Level logLevel() { return Level.FINE; } @@ -281,10 +335,11 @@ super((Frame)null, descriptor.getTitle(), descriptor.isModal()); } + @Override public void setVisible(boolean b) { if (isModal()) { super.setVisible(b); - } } } +} } \ No newline at end of file diff -r 81c86e07c313 options.api/test/unit/src/org/netbeans/api/options/RegisteredCategory.java --- a/options.api/test/unit/src/org/netbeans/api/options/RegisteredCategory.java Thu May 15 05:30:07 2008 +0200 +++ b/options.api/test/unit/src/org/netbeans/api/options/RegisteredCategory.java Thu May 15 13:07:20 2008 +0200 @@ -24,7 +24,7 @@ * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL @@ -106,6 +106,8 @@ } + public static String subcategoryID; + public OptionsPanelController create() { return new OptionsPanelController() { @@ -152,6 +154,11 @@ calls.add("getComponent()"); return new JLabel(); } + + @Override + public void setCurrentSubcategory(String id) { + subcategoryID = id; + } public void addPropertyChangeListener(PropertyChangeListener l) { propertyChangeListener = l; diff -r 81c86e07c313 options.api/test/unit/src/org/netbeans/api/options/mf-layer.xml --- a/options.api/test/unit/src/org/netbeans/api/options/mf-layer.xml Thu May 15 05:30:07 2008 +0200 +++ b/options.api/test/unit/src/org/netbeans/api/options/mf-layer.xml Thu May 15 13:07:20 2008 +0200 @@ -26,7 +26,7 @@ Contributor(s): The Original Software is NetBeans. The Initial Developer of the Original -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. If you wish your version of this file to be governed by only the CDDL @@ -47,5 +47,16 @@ + + + + + + + + + + +