private void splitTab(Component base, TabbedDockableContainer tdc,
			DockingConstants.Split position) {
		// should be used only when drag and dropping

		if (base == null)
			throw new NullPointerException("base");
		Dockable firstDockable = tdc.getDockableAt(0);
		DockableState currentState = getDockableState(firstDockable);
		boolean stateChange = false;
		if (currentState.isFloating()) {
			removePreviousFloatingStates(tdc); // clear reference of the
												// previous state
			stateChange = true;
		}

		Container oldContainer = (Container) tdc;
		int oldWidth = 0;
		int oldHeight = 0;
		if (oldContainer != null) {
			oldWidth = oldContainer.getWidth();
			oldHeight = oldContainer.getHeight();
		} else {
			oldWidth = base.getWidth() / 2;
			oldHeight = base.getHeight() / 2;
		}

		DockableContainer dockableContainer = tdc;

		// create a new splitcontainer that will replace baseDockable's
		// container
		SplitContainer split;
		if (position == DockingConstants.SPLIT_TOP
				|| position == DockingConstants.SPLIT_BOTTOM) {
			split = new SplitContainer(JSplitPane.VERTICAL_SPLIT);
		} else /*
				 * if (position == DockingConstants.SPLIT_LEFT || position ==
				 * DockingConstants.SPLIT_RIGHT)
				 */{
			split = new SplitContainer(JSplitPane.HORIZONTAL_SPLIT);
		}

		if (base != dockingPanel) { // 2005/11/08 support for splitting from
									// dockingPanel
			DockingUtilities.replaceChild(base.getParent(), base, split);

			if (position == DockingConstants.SPLIT_TOP
					|| position == DockingConstants.SPLIT_LEFT) {
				split.setLeftComponent((Component) dockableContainer);
				split.setRightComponent(base);
			} else {
				split.setRightComponent((Component) dockableContainer);
				split.setLeftComponent(base);
			}
		} else {
			// docking panel must remain the top level ancestor
			if (dockingPanel.getComponentCount() != 0) {
				Component dockingPanelChild = dockingPanel.getComponent(0);
				DockingUtilities.replaceChild(dockingPanel, dockingPanelChild,
						split);
				if (position == DockingConstants.SPLIT_TOP
						|| position == DockingConstants.SPLIT_LEFT) {
					split.setLeftComponent((Component) dockableContainer);
					split.setRightComponent(dockingPanelChild);
				} else {
					split.setRightComponent((Component) dockableContainer);
					split.setLeftComponent(dockingPanelChild);
				}
			} else { // dockingpanel is empty
				dockingPanel.add((Component) dockableContainer);
			}

		}

		// if (oldContainer != null){
		// now try to keep same size as before the drop
		// we do this in invokelater because split.getWidth()/getHeight()
		// returns 0 at this time
		// and we need this value to do a correct setDividerLocation.

		if (position == DockingConstants.SPLIT_TOP) {
			SwingUtilities.invokeLater(new SplitResizer(split, oldHeight));
		} else if (position == DockingConstants.SPLIT_BOTTOM) {
			SwingUtilities.invokeLater(new SplitResizer(split, -oldHeight));
		} else if (position == DockingConstants.SPLIT_LEFT) {
			SwingUtilities.invokeLater(new SplitResizer(split, oldWidth));
		} else if (position == DockingConstants.SPLIT_RIGHT) {
			SwingUtilities.invokeLater(new SplitResizer(split, -oldWidth));
		}
		// }

		if (stateChange) {
			// this part is tricky : we assume the caller is DragContoller (it's
			// the only
			// legal way to invoke this method). DragController triggers event
			// change

			for (int i = 0; i < tdc.getTabCount(); i++) {
				Dockable d = tdc.getDockableAt(i);
				DockableState newState = new DockableState(this, d,
						DockableState.Location.DOCKED);
				context.setDockableState(d, newState);
			}
		}

		// registerDockable(dockable);
		// dockableStates.put(dockable, newState);

		// if (stateChange){
		// dockable.getDockKey().setLocation(DockableState.DOCKED);
		// fireDockableStateChange(new DockableStateChangeEvent(currentState,
		// newState));
		// }
		//
		// removeFromTabbedGroup(dockable); //2005/10/10
		// DockingUtilities.updateResizeWeights(dockingPanel);
	}