# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: F:\Sources\MainTrunk\core\windows # 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/core/windows/model/DefaultModel.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\DefaultModel.java Base (1.24) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\DefaultModel.java Locally Modified (Based On 1.24) *************** *** 830,835 **** --- 830,844 ---- } } + public int getModeOpenedTopComponentPosition(ModeImpl mode, TopComponent tc) { + ModeModel modeModel = getModelForMode(mode); + if(modeModel != null) { + return modeModel.getOpenedTopComponentPosition(tc); + } else { + return -1; + } + } + public List getModeClosedTopComponentsIDs(ModeImpl mode) { ModeModel modeModel = getModelForMode(mode); if(modeModel != null) { Index: src/org/netbeans/core/windows/ModeImpl.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\ModeImpl.java Base (1.26) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\ModeImpl.java Locally Modified (Based On 1.26) *************** *** 293,314 **** getCentral().setUnloadedPreviousSelectedTopComponent(this, tcID); } - // XXX public List getOpenedTopComponentsIDs() { return getCentral().getModeOpenedTopComponentsIDs(this); } ! // XXX public List getClosedTopComponentsIDs() { return getCentral().getModeClosedTopComponentsIDs(this); } ! // XXX public List getTopComponentsIDs() { return getCentral().getModeTopComponentsIDs(this); } /** Sets and updates the state of associated frame, if frame exists. * Otherwise remembers state for futher use --- 293,315 ---- getCentral().setUnloadedPreviousSelectedTopComponent(this, tcID); } public List getOpenedTopComponentsIDs() { return getCentral().getModeOpenedTopComponentsIDs(this); } ! public List getClosedTopComponentsIDs() { return getCentral().getModeClosedTopComponentsIDs(this); } ! public List getTopComponentsIDs() { return getCentral().getModeTopComponentsIDs(this); } + /** Gets opened top component position in the mode */ + public int getTopComponentPosition(TopComponent tc) { + return getCentral().getModeTopComponentPosition(this, tc); + } + /** Sets and updates the state of associated frame, if frame exists. * Otherwise remembers state for futher use */ Index: src/org/netbeans/core/windows/Central.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\Central.java Base (1.53) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\Central.java Locally Modified (Based On 1.53) *************** *** 1374,1379 **** --- 1374,1385 ---- public List getModeOpenedTopComponents(ModeImpl mode) { return model.getModeOpenedTopComponents(mode); } + + /** Gets position of top component in given mode. */ + public int getModeTopComponentPosition(ModeImpl mode, TopComponent tc) { + return model.getModeOpenedTopComponentPosition(mode, tc); + } + /// << Mode specific //////////////////////////////// Index: src/org/netbeans/core/windows/model/TopComponentSubModel.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\TopComponentSubModel.java Base (1.15) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\TopComponentSubModel.java Locally Modified (Based On 1.15) *************** *** 232,237 **** --- 232,241 ---- return openedTopComponents.contains(tc) || tcIDs.contains(getID(tc)); } + public int getOpenedTopComponentPosition (TopComponent tc) { + return openedTopComponents.indexOf(tc); + } + public boolean isEmpty() { return tcIDs.isEmpty(); } Index: src/org/netbeans/core/windows/model/DefaultModeModel.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\DefaultModeModel.java Base (1.12) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\DefaultModeModel.java Locally Modified (Based On 1.12) *************** *** 286,291 **** --- 286,297 ---- } } + public int getOpenedTopComponentPosition (TopComponent tc) { + synchronized(LOCK_TOPCOMPONENTS) { + return topComponentSubModel.getOpenedTopComponentPosition(tc); + } + } + public SplitConstraint[] getTopComponentPreviousConstraints(String tcID) { synchronized(LOCK_TC_CONTEXTS) { return getContextSubModel().getTopComponentPreviousConstraints(tcID); Index: test/unit/src/org/netbeans/core/windows/OpenAtPositionTest.java *** F:\Sources\MainTrunk\core\windows\test\unit\src\org\netbeans\core\windows\OpenAtPositionTest.java No Base Revision --- F:\Sources\MainTrunk\core\windows\test\unit\src\org\netbeans\core\windows\OpenAtPositionTest.java Locally New *************** *** 1,0 **** --- 1,95 ---- + /* + * 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.*; + + + /** + * Tests correct behaviour of TopComponent.openAtPosition and TopComponent.getTabPosition. + * + * @author Dafe Simonek + */ + public class OpenAtPositionTest extends NbTestCase { + + public OpenAtPositionTest (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(OpenAtPositionTest.class); + + return suite; + } + + protected boolean runInEQ () { + return true; + } + + public void testIsOpenedAtRightPosition () throws Exception { + Mode mode = WindowManagerImpl.getInstance().createMode("testIsOpenedAtRightPositionMode", + Constants.MODE_KIND_EDITOR, Constants.MODE_STATE_JOINED, false, new SplitConstraint[0] ); + + TopComponent firstTC = new TopComponent(); + mode.dockInto(firstTC); + TopComponent tc1 = new TopComponent(); + mode.dockInto(tc1); + TopComponent tc2 = new TopComponent(); + mode.dockInto(tc2); + TopComponent tc3 = new TopComponent(); + mode.dockInto(tc3); + + System.out.println("Checking getPosition on closed TopComponent..."); + assertTrue("Expected TC position -1, but got " + tc1.getPosition(), tc1.getPosition() == -1); + + System.out.println("Checking open both on impossible and possible positions..."); + + firstTC.open(); + + tc1.openAtPosition(2); + assertTrue(tc1.isOpened()); + assertTrue("Expected TC position 1, but got " + tc1.getPosition(), tc1.getPosition() == 1); + + tc2.openAtPosition(-2); + assertTrue(tc2.isOpened()); + assertTrue("Expected TC position 0, but got " + tc2.getPosition(), tc2.getPosition() == 0); + + tc3.openAtPosition(1); + assertTrue(tc3.isOpened()); + assertTrue("Expected TC position 1, but got " + tc3.getPosition(), tc3.getPosition() == 1); + assertTrue("Expected TC position 3, but got " + tc1.getPosition(), tc1.getPosition() == 3); + assertTrue("Expected TC position 0, but got " + tc2.getPosition(), tc2.getPosition() == 0); + + tc3.close(); + assertTrue("Expected TC position -1, but got " + tc3.getPosition(), tc3.getPosition() == -1); + + } + + } Index: nbproject/project.xml *** F:\Sources\MainTrunk\core\windows\nbproject\project.xml Base (1.22) --- F:\Sources\MainTrunk\core\windows\nbproject\project.xml Locally Modified (Based On 1.22) *************** *** 128,134 **** ! 6.8 --- 128,134 ---- ! 6.15 Index: src/org/netbeans/core/windows/model/Model.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\Model.java Base (1.18) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\Model.java Locally Modified (Based On 1.18) *************** *** 264,269 **** --- 264,272 ---- /** Gets the tab index of the given top component before it was moved to sliding/separate mode */ public int getModeTopComponentPreviousIndex(ModeImpl mode, String tcID); + /** Gets position of given top component in given mode */ + public int getModeOpenedTopComponentPosition(ModeImpl mode, TopComponent tc); + // Accessors (mode level) << //////////////////////////// // Mode level << Index: src/org/netbeans/core/windows/WindowManagerImpl.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\WindowManagerImpl.java Base (1.59) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\WindowManagerImpl.java Locally Modified (Based On 1.59) *************** *** 1024,1030 **** // Manipulating methods (overriding the superclass dummy ones) >> ! protected void topComponentOpen(TopComponent tc) { assertEventDispatchThreadWeak(); if (tc == null) { --- 1024,1034 ---- // Manipulating methods (overriding the superclass dummy ones) >> ! protected void topComponentOpen (TopComponent tc) { ! topComponentOpenAtPosition(tc, -1); ! } ! ! protected void topComponentOpenAtPosition (TopComponent tc, int position) { assertEventDispatchThreadWeak(); if (tc == null) { *************** *** 1052,1058 **** --- 1056,1066 ---- switchMaximizedMode(null); } + if (position == -1) { mode.addOpenedTopComponent(tc); + } else { + mode.addOpenedTopComponent(tc, position); + } if( central.isEditorMaximized() && !alreadyOpened *************** *** 1068,1073 **** --- 1076,1092 ---- } } + protected int topComponentGetPosition (TopComponent tc) { + assertEventDispatchThreadWeak(); + + ModeImpl mode = getModeForOpenedTopComponent(tc); + if(mode != null) { + return mode.getTopComponentPosition(tc); + } else { + return -1; + } + } + protected void topComponentClose(TopComponent tc) { assertEventDispatchThreadWeak(); Index: src/org/netbeans/core/windows/model/ModeModel.java *** F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\ModeModel.java Base (1.11) --- F:\Sources\MainTrunk\core\windows\src\org\netbeans\core\windows\model\ModeModel.java Locally Modified (Based On 1.11) *************** *** 114,119 **** --- 114,120 ---- public SplitConstraint[] getTopComponentPreviousConstraints(String tcID); + /** Gets position of opened top component in this mode */ + public int getOpenedTopComponentPosition (TopComponent tc); }