# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\projects\nb.m7 # 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: openide/windows/apichanges.xml *** D:\projects\nb.m7\openide\windows\apichanges.xml Base (1.10) --- D:\projects\nb.m7\openide\windows\apichanges.xml Locally Modified (Based On 1.10) *************** *** 24,29 **** --- 24,43 ---- + + + Added a method to check the type of a TopComponent - 'editor' or 'view' + + + + + + + Added method isEditorTopComponent( TopComponent tc) to WindowManager that returns true if there is a Mode that + the TopComponent will be/is docked to and the Mode is of 'editor' kind (i.e. holds editor windows). + + + Generics Index: core/windows/src/org/netbeans/core/windows/WindowManagerImpl.java *** D:\projects\nb.m7\core\windows\src\org\netbeans\core\windows\WindowManagerImpl.java Base (1.56) --- D:\projects\nb.m7\core\windows\src\org\netbeans\core\windows\WindowManagerImpl.java Locally Modified (Based On 1.56) *************** *** 1175,1180 **** --- 1175,1200 ---- exclusive.register(run); } + @Override + public boolean isEditorTopComponent( TopComponent tc ) { + for( Iterator it = getModes().iterator(); it.hasNext(); ) { + ModeImpl mode = (ModeImpl)it.next(); + + if( mode.containsTopComponent( tc ) ) { + return isEditorMode( mode ); + } + } + + //unknown TopComponent + return false; + } + + @Override + public boolean isEditorMode( Mode mode ) { + ModeImpl modeImpl = findModeImpl( mode.getName() ); + return null != modeImpl && modeImpl.getKind() == Constants.MODE_KIND_EDITOR; + } + /** Handles exclusive invocation of Runnables. */ private static final class Exclusive implements Runnable { Index: core/windows/test/unit/src/org/netbeans/core/windows/TopComponentTypeTest.java *** D:\projects\nb.m7\core\windows\test\unit\src\org\netbeans\core\windows\TopComponentTypeTest.java No Base Revision --- D:\projects\nb.m7\core\windows\test\unit\src\org\netbeans\core\windows\TopComponentTypeTest.java Locally New *************** *** 1,0 **** --- 1,81 ---- + /* + * 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 2002 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.core.windows; + + import junit.framework.*; + import org.netbeans.junit.*; + + import org.openide.windows.*; + + + /** + * Ensure that TopComponent type - "editor" / "view" - is interpreted correctly. + * + * @author S. Aubrecht + */ + public class TopComponentTypeTest extends NbTestCase { + + public TopComponentTypeTest (String name) { + super (name); + } + + /** + * @param args the command line arguments + */ + public static void main(java.lang.String[] args) { + junit.textui.TestRunner.run(suite()); + } + + public static Test suite() { + TestSuite suite = new NbTestSuite(TopComponentTypeTest.class); + + return suite; + } + + protected boolean runInEQ () { + return true; + } + + public void testIsEditorTopComponent () throws Exception { + TopComponent tc = new TopComponent (); + Mode mode = WindowManagerImpl.getInstance().createMode( "editorMode", Constants.MODE_KIND_EDITOR, Constants.MODE_STATE_JOINED, false, new SplitConstraint[0] ); + mode.dockInto( tc ); + + assertTrue( WindowManagerImpl.getInstance().isEditorTopComponent( tc ) ); + assertTrue( WindowManagerImpl.getInstance().isEditorMode( mode ) ); + } + + public void testIsViewTopComponent () throws Exception { + TopComponent tc = new TopComponent (); + Mode mode = WindowManagerImpl.getInstance().createMode( "viewMode", Constants.MODE_KIND_VIEW, Constants.MODE_STATE_JOINED, false, new SplitConstraint[0] ); + mode.dockInto( tc ); + + assertFalse( WindowManagerImpl.getInstance().isEditorTopComponent( tc ) ); + assertFalse( WindowManagerImpl.getInstance().isEditorMode( mode ) ); + } + + public void testUnknownTopComponent () throws Exception { + TopComponent tc = new TopComponent (); + //no mode defined for the topcomponent + + assertFalse( WindowManagerImpl.getInstance().isEditorTopComponent( tc ) ); + } + } + Index: openide/windows/src/org/openide/windows/WindowManager.java *** D:\projects\nb.m7\openide\windows\src\org\openide\windows\WindowManager.java Base (1.13) --- D:\projects\nb.m7\openide\windows\src\org\openide\windows\WindowManager.java Locally Modified (Based On 1.13) *************** *** 493,498 **** --- 493,525 ---- EventQueue.invokeLater(run); } + /** + *

Check whether the given TopComponent will be/is docked into an 'editor' Mode.

+ *

Please note that some TopComponents may be docked into 'editor' modes as well as + * 'view' modes, see method isTopComponentAllowedToMoveAnywhere().

+ * + * @param tc TopComponent to check. + * @return True if there is a Mode that the TopComponent will be/is docked to and + * the Mode is of 'editor' kind (i.e. holds editor windows). + * @since 6.13 + */ + public boolean isEditorTopComponent( TopComponent tc ) { + return false; + } + + /** + *

Check whether the given Mode holds editor windows.

+ *

Please note that some TopComponents may be docked into 'editor' modes as well as + * 'view' modes, see method isTopComponentAllowedToMoveAnywhere().

+ * + * @param mode Mode to check. + * @return True the Mode contains editor windows. + * @since 6.13 + */ + public boolean isEditorMode( Mode mode ) { + return false; + } + /** A manager that handles operations on top components. * It is always attached to a {@link TopComponent}. * @deprecated Do not use anymore. This interface is replaced by bunch of protected methods Index: openide/windows/manifest.mf *** D:\projects\nb.m7\openide\windows\manifest.mf Base (1.12) --- D:\projects\nb.m7\openide\windows\manifest.mf Locally Modified (Based On 1.12) *************** *** 1,5 **** Manifest-Version: 1.0 OpenIDE-Module: org.openide.windows ! OpenIDE-Module-Specification-Version: 6.12 OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties --- 1,5 ---- Manifest-Version: 1.0 OpenIDE-Module: org.openide.windows ! OpenIDE-Module-Specification-Version: 6.13 OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties