# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\projects\nb.new\core\palette # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: manifest.mf *** D:\projects\nb.new\core\palette\manifest.mf Base (1.12) --- D:\projects\nb.new\core\palette\manifest.mf Locally Modified (Based On 1.12) *************** *** 1,6 **** Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.spi.palette/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/palette/resources/Bundle.properties ! OpenIDE-Module-Specification-Version: 1.10 OpenIDE-Module-Layer: org/netbeans/modules/palette/resources/layer.xml --- 1,6 ---- Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.spi.palette/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/palette/resources/Bundle.properties ! OpenIDE-Module-Specification-Version: 1.11 OpenIDE-Module-Layer: org/netbeans/modules/palette/resources/layer.xml Index: api/doc/changes/apichanges.xml *** D:\projects\nb.new\core\palette\api\doc\changes\apichanges.xml Base (1.17) --- D:\projects\nb.new\core\palette\api\doc\changes\apichanges.xml Locally Modified (Based On 1.17) *************** *** 255,260 **** --- 255,278 ---- + + + Palette providers may need to define their own action that + resets the palette to its default state. + + + + + +

+ Now it's possible to provide an action that will be invoked when user chose 'Reset' + in palette's popup menu or in Palette Manager window. +

+
+ + +
+ Index: src/org/netbeans/spi/palette/PaletteActions.java *** D:\projects\nb.new\core\palette\src\org\netbeans\spi\palette\PaletteActions.java Base (1.4) --- D:\projects\nb.new\core\palette\src\org\netbeans\spi\palette\PaletteActions.java Locally Modified (Based On 1.4) *************** *** 78,84 **** --- 78,98 ---- public Action getRefreshAction() { return null; } + + /** + * An action that resets the palette content to its default state. The action can be + * invoked by the user from palette's popup menu for from the Palette Manager window. + * The action properties (label, icon) are not displayed to the user, the Palette module + * provides its own. + * @return Custom reset action or null to use the default one that removes all user's + * modifications to the XML layer files. + * @since 1.11 + */ + public Action getResetAction() { + return null; } + } Index: src/org/netbeans/modules/palette/Utils.java *** D:\projects\nb.new\core\palette\src\org\netbeans\modules\palette\Utils.java Base (1.14) --- D:\projects\nb.new\core\palette\src\org\netbeans\modules\palette\Utils.java Locally Modified (Based On 1.14) *************** *** 35,40 **** --- 35,41 ---- import javax.swing.*; import org.netbeans.spi.palette.PaletteController; import org.netbeans.modules.palette.ui.PalettePanel; + import org.netbeans.spi.palette.PaletteActions; import org.openide.*; import org.openide.loaders.DataObject; *************** *** 145,156 **** public static void resetPalette( final PaletteController controller, final Settings settings ) { Node rootNode = (Node)controller.getRoot().lookup( Node.class ); ! if( null != rootNode ) resetPalette( rootNode, controller, settings ); } public static void resetPalette( Node rootNode, PaletteController controller, Settings settings ) { --- 146,163 ---- public static void resetPalette( final PaletteController controller, final Settings settings ) { Node rootNode = (Node)controller.getRoot().lookup( Node.class ); ! if( null != rootNode ) { ! PaletteActions customActions = rootNode.getLookup().lookup( PaletteActions.class ); ! Action resetAction = customActions.getResetAction(); ! if( null != resetAction ) { ! settings.reset(); ! resetAction.actionPerformed( new ActionEvent( controller, 0, "reset" ) ); //NOI18N ! controller.refresh(); ! } else { resetPalette( rootNode, controller, settings ); } + } + } public static void resetPalette( Node rootNode, PaletteController controller, Settings settings ) { // first user confirmation... Index: test/unit/src/org/netbeans/spi/palette/PaletteControllerTest.java *** D:\projects\nb.new\core\palette\test\unit\src\org\netbeans\spi\palette\PaletteControllerTest.java Base (1.5) --- D:\projects\nb.new\core\palette\test\unit\src\org\netbeans\spi\palette\PaletteControllerTest.java Locally Modified (Based On 1.5) *************** *** 19,32 **** --- 19,36 ---- package org.netbeans.spi.palette; + import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; + import javax.swing.AbstractAction; + import javax.swing.Action; import junit.framework.TestCase; import org.netbeans.modules.palette.Category; import org.netbeans.modules.palette.Item; import org.netbeans.modules.palette.Model; import org.netbeans.modules.palette.Settings; + import org.netbeans.modules.palette.Utils; import org.openide.nodes.Node; import org.openide.util.Lookup; *************** *** 188,202 **** /** * Test of resetPalette method, of class org.netbeans.modules.palette.api.PaletteController. */ ! public void testResetPalette() { ! // System.out.println("testResetPalette"); ! // ! // PaletteController instance = null; ! // ! // instance.resetPalette(); ! // ! // // TODO add your test code below by replacing the default call to fail. ! // fail("The test case is empty."); } /** --- 192,203 ---- /** * Test of resetPalette method, of class org.netbeans.modules.palette.api.PaletteController. */ ! public void testCustomResetPalette() { ! MyActions actions = new MyActions(); ! PaletteController myController = PaletteFactory.createPalette( DummyPalette.createPaletteRoot(), actions, null, null ); ! ! Utils.resetPalette( myController, settings ); ! assertTrue( actions.customResetInvoked ); } /** *************** *** 327,333 **** --- 328,369 ---- this.isEnabled = enable; } } + + private static class MyActions extends PaletteActions { + + boolean customResetInvoked = false; + + public Action[] getImportActions() { + return null; } + + public Action[] getCustomPaletteActions() { + return null; + } + + public Action[] getCustomCategoryActions(Lookup category) { + return null; + } + + public Action[] getCustomItemActions(Lookup item) { + return null; + } + + public Action getPreferredAction(Lookup item) { + return null; + } + + @Override + public Action getResetAction() { + return new AbstractAction() { + public void actionPerformed(ActionEvent arg0) { + customResetInvoked = true; + } + }; + } + } + }