Index: openide/loaders/src/org/openide/text/EditorSupport.java @@ -47,7 +47,12 @@ * @deprecated Use DataEditorSupport instead */ public class EditorSupport extends OpenSupport -implements EditorCookie.Observable, OpenCookie, CloseCookie, PrintCookie { +implements EditorCookie.Observable, OpenCookie, CloseCookie, PrintCookie +// <> +// So that we can obtain the undoredo for the Java editor top components + , org.openide.cookies.UndoRedoCookie +// + { /** Common name for editor mode. * @deprecated Use {@link org.openide.text.CloneableEditorSupport#EDITOR_MODE} instead. */ @@ -436,6 +441,14 @@ del.superNotifyClosed (); } + // <> + // Useful for test suite + // XXX #5055050 and now also in project exit dialog. + public void closeDocumentPublic() { + del.closeDocumentPublic(); + } + // + /** Utility method to extract EditorSupport from Del instance. * @param ces cloneable editor support @@ -940,4 +953,14 @@ return o; } } + + +// <> +// So that we can obtain the undoredo for the Java editor top components + // ------- implements UndoRedoCookie + public UndoRedo getUndoRedoI() { + return del.getUndoRedoI(); + } +// + } Index: openide/src/org/openide/cookies/UndoRedoCookie.java @@ -0,0 +1,34 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.openide.cookies; + +import org.openide.awt.UndoRedo; +import org.openide.nodes.Node; + +/** Cookie for obtaining the UndoRedo +* +* @author Tor Norbye +* @since +*/ +public interface UndoRedoCookie extends Node.Cookie { + + /** Return the undo redo object */ + public UndoRedo getUndoRedoI(); + // This was named getUndoRedoI instead of the preferrable + // getUndoRedo because some objects that needed to implement + // this interface, notably ClonableEditorSupport, already had + // a conflicting method named getUndoRedo. I then tried calling + // it getUndoRedoManager, and ran into another conflict in the + // properties module. So hopefully this new name will be unique enough. +} Index: openide/src/org/openide/text/CloneableEditorSupport.java @@ -76,7 +76,12 @@ * * @author Jaroslav Tulach */ -public abstract class CloneableEditorSupport extends CloneableOpenSupport { +public abstract class CloneableEditorSupport extends CloneableOpenSupport +// <> +// So that we can obtain the undoredo for the editor top components + implements org.openide.cookies.UndoRedoCookie +// +{ /** Common name for editor mode. */ public static final String EDITOR_MODE = "editor"; // NOI18N @@ -266,6 +271,13 @@ return kit; } +// <> +// So that we can obtain the undoredo for the Java editor top components + // ------- implements UndoRedoCookie + public UndoRedo getUndoRedoI() { + return getUndoRedo(); + } +// /** * Gets the undo redo manager. Index: core/src/org/netbeans/core/NbSheet.java @@ -552,4 +595,32 @@ } // End of SheetNodesListener. +// <> +// Need to get UndoRedo also from Property sheet. +// Trying to find UndoRedo from the nodes lookup. + public org.openide.awt.UndoRedo getUndoRedo() { + Node[] ns = nodes; + + if(ns != null) { + for(int i = 0; i < ns.length; i++) { + Node n = ns[i]; + if(n == null) { + continue; + } + org.openide.cookies.UndoRedoCookie urc = + (org.openide.cookies.UndoRedoCookie)n.getLookup(). + lookup(org.openide.cookies.UndoRedoCookie.class); + org.openide.awt.UndoRedo undoRedo = null; + if (urc != null) { + undoRedo = urc.getUndoRedoI(); + if(undoRedo != null) { + return undoRedo; + } + } + } + } + + return super.getUndoRedo(); + } +// }