# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\projects\nb.m7\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: src/org/netbeans/modules/palette/DefaultModel.java *** D:\projects\nb.m7\core\palette\src\org\netbeans\modules\palette\DefaultModel.java Base (1.12) --- D:\projects\nb.m7\core\palette\src\org\netbeans\modules\palette\DefaultModel.java Locally Modified (Based On 1.12) *************** *** 19,24 **** --- 19,25 ---- package org.netbeans.modules.palette; + import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeSupport; import java.util.ArrayList; *************** *** 28,33 **** --- 29,35 ---- import org.openide.nodes.*; import org.openide.util.*; import org.netbeans.modules.palette.ui.Customizer; + import org.netbeans.spi.palette.PaletteActions; /** * Default implementation of PaletteModel interface based on Nodes. *************** *** 225,230 **** --- 227,237 ---- private boolean isRefreshingChildren = false; public void refresh() { + PaletteActions customActions = (PaletteActions)rootNode.getLookup().lookup( PaletteActions.class ); + Action customRefreshAction = customActions.getRefreshAction(); + if( null != customRefreshAction ) { + customRefreshAction.actionPerformed( new ActionEvent( getRoot(), 0, "refresh" ) ); //NOI18N + } clearSelection(); categories = null; isRefreshingChildren = true; Index: manifest.mf *** D:\projects\nb.m7\core\palette\manifest.mf Base (1.10) --- D:\projects\nb.m7\core\palette\manifest.mf Locally Modified (Based On 1.10) *************** *** 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.7 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.9 OpenIDE-Module-Layer: org/netbeans/modules/palette/resources/layer.xml Index: api/doc/changes/apichanges.xml *** D:\projects\nb.m7\core\palette\api\doc\changes\apichanges.xml Base (1.14) --- D:\projects\nb.m7\core\palette\api\doc\changes\apichanges.xml Locally Modified (Based On 1.14) *************** *** 211,216 **** --- 211,232 ---- + + + + Palette providers need to be notified when the palette content is being refreshed. + + + + + +

+ Now it's possible to provide an action that will be invoked as part of palette's 'refresh' logic. +

+
+ + +
Index: src/org/netbeans/spi/palette/PaletteActions.java *** D:\projects\nb.m7\core\palette\src\org\netbeans\spi\palette\PaletteActions.java Base (1.3) --- D:\projects\nb.m7\core\palette\src\org\netbeans\spi\palette\PaletteActions.java Locally Modified (Based On 1.3) *************** *** 20,26 **** package org.netbeans.spi.palette; - import java.awt.event.InputEvent; import javax.swing.Action; import org.openide.util.Lookup; --- 20,25 ---- *************** *** 67,73 **** --- 66,85 ---- * Return null to disable preferred action for this item. */ public abstract Action getPreferredAction( Lookup item ); + + /** + * An action that will be invoked as part of the palette refresh logic, + * for example when user chooses "Refresh" in palette's popup menu. Can be null. + * The action properties (label, icon) are not displayed to the user, the Palette module + * will provide its own. + * @return Custom refresh action or null. + * @since 1.9 + */ + public Action getRefreshAction() { + return null; } + } Index: test/unit/src/org/netbeans/spi/palette/ModelTest.java *** D:\projects\nb.m7\core\palette\test\unit\src\org\netbeans\spi\palette\ModelTest.java Base (1.5) --- D:\projects\nb.m7\core\palette\test\unit\src\org\netbeans\spi\palette\ModelTest.java Locally Modified (Based On 1.5) *************** *** 19,25 **** --- 19,27 ---- package org.netbeans.spi.palette; + import java.awt.event.ActionEvent; import java.io.IOException; + import javax.swing.AbstractAction; import javax.swing.Action; import org.netbeans.modules.palette.Category; import org.netbeans.modules.palette.Item; *************** *** 188,194 **** --- 190,229 ---- assertEquals( source, movedCategories[0] ); } + /** + * Test of getName method, of class org.netbeans.modules.palette.Model. + */ + public void testCustomRefresh() throws IOException { + CustomRefresh refresh = new CustomRefresh(); + PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), new CustomRefreshActions( refresh ) ); + pc.refresh(); + assertTrue( refresh.actionInvoked ); } + + private static class CustomRefreshActions extends DummyActions { + private Action refresh; + public CustomRefreshActions( Action refresh ) { + this.refresh = refresh; + } + + @Override + public Action getRefreshAction() { + return refresh; + } + } + + private static class CustomRefresh extends AbstractAction { + private boolean actionInvoked = false; + + public CustomRefresh() { + } + + public void actionPerformed(ActionEvent arg0) { + actionInvoked = true; + } + } + }