# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: F:\Sources\MainTrunk\core\navigator # 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: apichanges.xml *** F:\Sources\MainTrunk\core\navigator\apichanges.xml Base (1.4) --- F:\Sources\MainTrunk\core\navigator\apichanges.xml Locally Modified (Based On 1.4) *************** *** 19,25 **** Microsystems, Inc. All Rights Reserved. --> ! ! ! Added API class NavigatorHandler and API method NavigatorHandler.activatePanel. --- 82,108 ---- ! ! + Added SPI interface NavigatorPanelWithUndo. + + + + + + NavigatorPanelWithUndo is new SPI interface which extands NavigatorPanel + by support for undoing and redoing changes in navigation views. + Method NavigatorPanelWithUndo.getUndoRedo() allows clients + to specify UndoRedo support that will be propagated to the + Navigator TopComponent when this panel is active in navigation area. + + + + + + + Added API class NavigatorHandler and API method NavigatorHandler.activatePanel. *************** *** 95,100 **** --- 114,120 ---- to programmatically activate the panel - panel becomes active and visible in navigator area. + Index: src/org/netbeans/modules/navigator/NavigatorController.java *** F:\Sources\MainTrunk\core\navigator\src\org\netbeans\modules\navigator\NavigatorController.java Base (1.17) --- F:\Sources\MainTrunk\core\navigator\src\org\netbeans\modules\navigator\NavigatorController.java Locally Modified (Based On 1.17) *************** *** 38,43 **** --- 38,45 ---- import javax.swing.SwingUtilities; import org.netbeans.spi.navigator.NavigatorLookupHint; import org.netbeans.spi.navigator.NavigatorPanel; + import org.netbeans.spi.navigator.NavigatorPanelWithUndo; + import org.openide.awt.UndoRedo; import org.openide.filesystems.FileObject; import org.openide.loaders.DataShadow; import org.openide.nodes.Node; *************** *** 363,368 **** --- 365,381 ---- return curNode.getLookup(); } + /** Retrieves and returns UndoRedo support from selected panel if panel + * offers UndoRedo (implements NavigatorPanelWithUndo). + */ + UndoRedo getUndoRedo () { + NavigatorPanel panel = navigatorTC.getSelectedPanel(); + if (panel == null || !(panel instanceof NavigatorPanelWithUndo)) { + return UndoRedo.NONE; + } + return ((NavigatorPanelWithUndo)panel).getUndoRedo(); + } + /** Installs user actions handling for NavigatorTC top component */ public void installActions () { // ESC key handling - return focus to previous focus owner Index: test/unit/src/org/netbeans/modules/navigator/NavigatorTCTest.java *** F:\Sources\MainTrunk\core\navigator\test\unit\src\org\netbeans\modules\navigator\NavigatorTCTest.java Base (1.7) --- F:\Sources\MainTrunk\core\navigator\test\unit\src\org\netbeans\modules\navigator\NavigatorTCTest.java Locally Modified (Based On 1.7) *************** *** 19,40 **** package org.netbeans.modules.navigator; - import java.awt.event.ActionEvent; - import java.awt.event.ActionListener; import java.util.List; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; - import javax.swing.Timer; import org.netbeans.junit.NbTest; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.NbTestSuite; import org.netbeans.spi.navigator.NavigatorHandler; import org.netbeans.spi.navigator.NavigatorLookupHint; import org.netbeans.spi.navigator.NavigatorPanel; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; --- 19,36 ---- package org.netbeans.modules.navigator; import java.util.List; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import org.netbeans.junit.NbTest; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.NbTestSuite; import org.netbeans.spi.navigator.NavigatorHandler; import org.netbeans.spi.navigator.NavigatorLookupHint; import org.netbeans.spi.navigator.NavigatorPanel; + import org.netbeans.spi.navigator.NavigatorPanelWithUndo; + import org.openide.awt.UndoRedo; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; *************** *** 177,182 **** --- 176,182 ---- List panels = navTC.getPanels(); + assertNotNull("Selected panel should not be null", navTC.getSelectedPanel()); assertTrue("Expected 2 provider panels, but got " + panels.size(), panels.size() == 2); NavigatorHandler.activatePanel(panels.get(1)); *************** *** 231,237 **** navTC.componentOpened(); List panels = navTC.getPanels(); ! assertTrue("Expected 1 provider panel, but got " + panels.size(), panels.size() == 1); assertTrue("Panel class not expected", panels.get(0) instanceof ActNodeLookupProvider); ActNodeLookupProvider provider = (ActNodeLookupProvider)panels.get(0); --- 231,238 ---- navTC.componentOpened(); List panels = navTC.getPanels(); ! assertNotNull("Selected panel should not be null", navTC.getSelectedPanel()); ! assertTrue("Expected 1 provider panel, but got " + panels.size(), panels != null && panels.size() == 1); assertTrue("Panel class not expected", panels.get(0) instanceof ActNodeLookupProvider); ActNodeLookupProvider provider = (ActNodeLookupProvider)panels.get(0); *************** *** 246,253 **** assertNotNull("Activated nodes musn't be null", actNodes); assertTrue("Expected 1 activated node, but got " + actNodes.length, actNodes.length == 1); - System.out.println("realContent: " + realContent); - System.out.println("act node: " + actNodes[0]); assertTrue("Incorrect instance of activated node " + actNodes[0].getName(), actNodes[0] == realContent); // change provider's lookup content and check again, to test infrastructure --- 247,252 ---- *************** *** 258,265 **** assertNotNull("Activated nodes musn't be null", actNodes); assertTrue("Expected 1 activated node, but got " + actNodes.length, actNodes.length == 1); - System.out.println("realContent: " + realContent); - System.out.println("act node: " + actNodes[0]); assertTrue("Incorrect instance of activated node " + actNodes[0].getName(), actNodes[0] == realContent); // cleanup --- 257,262 ---- *************** *** 267,272 **** --- 264,301 ---- navTC.componentClosed(); } + /** Test for IZ feature #98125. It tests ability of NavigatorPanelWithUndo + * implementors to provide UndoRedo support for their view through + * navigator TopComponent. + */ + public void testFeature98125_UndoRedo () throws Exception { + System.out.println("Testing feature #98125, providing UndoRedo..."); + + InstanceContent ic = getInstanceContent(); + + TestLookupHint undoHint = new TestLookupHint("undoRedo/tester"); + ic.add(undoHint); + + NavigatorTC navTC = NavigatorTC.getInstance(); + navTC.componentOpened(); + + NavigatorPanel selPanel = navTC.getSelectedPanel(); + assertNotNull("Selected panel should not be null", navTC.getSelectedPanel()); + assertTrue("Panel class not expected", selPanel instanceof UndoRedoProvider); + UndoRedoProvider provider = (UndoRedoProvider)selPanel; + + UndoRedo panelUndo = provider.getUndoRedo(); + UndoRedo tcUndo = navTC.getUndoRedo(); + + assertTrue("Expected undo manager " + panelUndo + ", but got " + tcUndo, panelUndo == tcUndo); + + // cleanup + ic.remove(undoHint); + navTC.componentClosed(); + + } + + /** Singleton global lookup. Lookup change notification won't come * if setting global lookup (UnitTestUtils.prepareTest) is called * multiple times. *************** *** 457,462 **** --- 486,531 ---- } } + /** + * Test implementation of NavigatorPanelWithUndo which enables undo/redo support. + */ + public static final class UndoRedoProvider implements NavigatorPanelWithUndo { + + private UndoRedo undo; + + public UndoRedo getUndoRedo() { + if (undo == null) { + undo = new UndoRedo.Manager(); + } + return undo; + } + + public String getDisplayName() { + return "UndoRedo provider"; + } + + public String getDisplayHint() { + return null; + } + + public JComponent getComponent() { + return new JLabel("test"); + } + + public void panelActivated(Lookup context) { + // no operation + } + + public void panelDeactivated() { + // no operation + } + + public Lookup getLookup() { + return null; + } + + } + /** Envelope for textual (mime-type like) content type to be used in * global lookup */ Index: src/org/netbeans/spi/navigator/NavigatorPanelWithUndo.java *** F:\Sources\MainTrunk\core\navigator\src\org\netbeans\spi\navigator\NavigatorPanelWithUndo.java No Base Revision --- F:\Sources\MainTrunk\core\navigator\src\org\netbeans\spi\navigator\NavigatorPanelWithUndo.java Locally New *************** *** 1,0 **** --- 1,47 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (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.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.spi.navigator; + + import org.openide.awt.UndoRedo; + + /** Description of navigation view with undo/redo support on top of basic + * NavigatorPanel features. + * + * Clients will implement this interface when they need undo and redo support + * enabled for their Navigator view/panel. + * + * Implementors of this interface, also registered in layer, + * will be plugged into Navigator UI. + * + * @author Dafe Simonek + */ + public interface NavigatorPanelWithUndo extends NavigatorPanel { + + /** Returns instance of UndoRedo which will be propagated into + * Navigator TopComponent's getUndoRedo() when this panel is active. + * + * It allows clients to enable undo/redo management and undo/redo actions for + * this panel in Navigator. + * + * @return Instance of UndoRedo. + */ + public UndoRedo getUndoRedo (); + + } Index: test/unit/src/org/netbeans/modules/navigator/resources/testCorrectCallsOfNavigatorPanelMethodsLayer.xml *** F:\Sources\MainTrunk\core\navigator\test\unit\src\org\netbeans\modules\navigator\resources\testCorrectCallsOfNavigatorPanelMethodsLayer.xml Base (1.4) --- F:\Sources\MainTrunk\core\navigator\test\unit\src\org\netbeans\modules\navigator\resources\testCorrectCallsOfNavigatorPanelMethodsLayer.xml Locally Modified (Based On 1.4) *************** *** 54,59 **** --- 54,69 ---- + + + + + + + + + + + Index: arch.xml *** F:\Sources\MainTrunk\core\navigator\arch.xml Base (1.11) --- F:\Sources\MainTrunk\core\navigator\arch.xml Locally Modified (Based On 1.11) *************** *** 362,367 **** --- 362,412 ---- + +

Some complex navigation views need support for undoing and redoing + edit changes done either directly in the view or in document which + the view is representing. +

+ + Steps to support undo and redo in navigation view: + +
    +
  • Implement your navigation view as NavigatorPanelWithUndo, + which is NavigatorPanel interface with extra method + getUndoRedo(). +

    +
  • + +
  • All other things remain the same as with basic NavigatorPanel usage. + UndoRedo support returned from NavigatorPanelWithUndo.getUndoRedo() + is propagated to the Navigator TopComponent and returned as its + UndoRedo support. For details see + TopComponent.getUndoRedo() + and UndoRedo interface. +

    +
  • + +
  • Example of NavigatorPanelWithUndo implementation: +
    +         class MyNavigatorPanelWithUndo implements NavigatorPanelWithUndo {
    +         
    +             /** UndoRedo support, substitute with your impl */
    +             private final UndoRedo undo = new UndoRedo.Manager();
    +         
    +             public UndoRedo getUndoRedo () {
    +                 return undo;
    +             }
    +             
    +             ... rest of the NavigatorPanelWithUndo impl ...
    + 
    +         }
    +              
    +
  • + +
+ +
+ Index: nbproject/project.xml *** F:\Sources\MainTrunk\core\navigator\nbproject\project.xml Base (1.5) --- F:\Sources\MainTrunk\core\navigator\nbproject\project.xml Locally Modified (Based On 1.5) *************** *** 21,53 **** org.netbeans.modules.apisupport.project - org.netbeans.spi.navigator - - ! org.openide.filesystems ! 6.2 - ! org.openide.util 6.2 - org.openide.nodes --- 21,51 ---- org.netbeans.modules.apisupport.project org.netbeans.spi.navigator ! org.openide.awt ! 6.10 ! org.openide.filesystems 6.2 + org.openide.loaders + + + + + org.openide.nodes *************** *** 52,74 **** 6.2 - ! org.openide.windows 6.2 - ! org.openide.loaders ! - --- 53,77 ---- 6.2 ! org.openide.util 6.2 ! org.openide.windows ! ! 6.2 ! *************** *** 95,105 **** - org.netbeans.spi.navigator - --- 95,103 ---- Index: manifest.mf *** F:\Sources\MainTrunk\core\navigator\manifest.mf Base (1.6) --- F:\Sources\MainTrunk\core\navigator\manifest.mf Locally Modified (Based On 1.6) *************** *** 2,5 **** OpenIDE-Module: org.netbeans.spi.navigator/1 OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties ! OpenIDE-Module-Specification-Version: 1.4 --- 2,5 ---- OpenIDE-Module: org.netbeans.spi.navigator/1 OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties ! OpenIDE-Module-Specification-Version: 1.5 Index: nbproject/project.properties *** F:\Sources\MainTrunk\core\navigator\nbproject\project.properties Base (1.8) --- F:\Sources\MainTrunk\core\navigator\nbproject\project.properties Locally Modified (Based On 1.8) *************** *** 20,25 **** --- 20,25 ---- javac.compilerargs=-Xlint:unchecked javac.source=1.5 javadoc.arch=${basedir}/arch.xml + javadoc.apichanges=${basedir}/apichanges.xml Index: src/org/netbeans/modules/navigator/NavigatorTC.java *** F:\Sources\MainTrunk\core\navigator\src\org\netbeans\modules\navigator\NavigatorTC.java Base (1.12) --- F:\Sources\MainTrunk\core\navigator\src\org\netbeans\modules\navigator\NavigatorTC.java Locally Modified (Based On 1.12) *************** *** 40,45 **** --- 40,46 ---- import javax.swing.UIManager; import org.netbeans.spi.navigator.NavigatorPanel; import org.openide.ErrorManager; + import org.openide.awt.UndoRedo; import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.openide.util.NbBundle; *************** *** 238,244 **** --- 239,247 ---- // << Window system + // << Window system + /** Combines default Lookup of TC with lookup from active navigator * panel. */ *************** *** 253,258 **** --- 256,266 ---- return navTCLookup; } + @Override + public UndoRedo getUndoRedo() { + return getController().getUndoRedo(); + } + /** Accessor for controller which controls UI behaviour */ public NavigatorController getController () { if (controller == null) {