Dragging dockables out of (into) CWorkingArea

Hi Beni,

I would like to have a CWorkingArea that allows dragging dockables out of it and dragging dockables into it from outside.
I looked at tutorial.common.basics.OpeningEditorsExample and changed line 34:
final CWorkingArea work = control.createWorkingArea( "work" );
with:

    final CWorkingArea work = new CWorkingArea(control, "work")
    {
      public boolean isWorkingArea()
      {
        return false;
      }

    };
control.addDockable(work);
control.addStation(work, true);	

It looks a bit hacky, is there another proper way to get such working area?

I also found a bug while running the above example.
You can run the original code from the tutorial:

  1. open two editors, they are stacked in the working area (Editor 0, Editor 1)
  2. externalize the editor stack
  3. drag one of the dockables from inside main window (Outline or Console) onto the editor stack.
  4. you now have two editors and one additional dockable in an external stack.
  5. press the unexternalize button, the 3rd dockable comes back to main window, the editors disappear.

If you run with my modification you get an exception:
java.lang.IllegalStateException: the parent of ‘bibliothek.gui.dock.common.intern.DefaultCommonDockable@6ecec5’ is not ‘bibliothek.gui.dock.StackDockStation@1d06d02’ but ‘null’

kind regards,
Maciej Modelski

Instead of “createWorkingArea” you can use “createGridArea” - you get a CStation that behaves just like a CWorkingArea - but does allow the Dockables to be moved around more freely.

Don’t know yet about the bug you described, I’ll see if I can reproduce it.

I could reproduce this bug, it will be fixed in the next version.

Thanks for reporting it (it was just a missing if-statement).

Cool, thanks!

BTW, you can also reproduce the bug with the GridArea, you get the same exception I mentioned above.

I hoped the exception would be gone… I’ll have a closer look.

I tried to reproduce the exception, but I seem to miss something. Could you please tell me how I have to modify my application to get the exception? Or how I have to move the Dockables?


import javax.swing.JFrame;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.CGridArea;
import bibliothek.gui.dock.common.DefaultSingleCDockable;

public class EditorTest {
	public static void main( String[] args ){
		JFrame frame = new JFrame();
		CControl control = new CControl( frame );
		
		frame.add( control.getContentArea() );
		
		CGridArea area = control.createGridArea( "grid" );
		area.setTitleShown( true );
		CGrid grid = new CGrid( control );
		grid.add( 0, 0, 1, 5, new DefaultSingleCDockable( "a", "Aaaaa" ) );
		grid.add( 1, 4, 4, 1, new DefaultSingleCDockable( "b", "Bbbbb" ) );
		grid.add( 1, 0, 4, 4, area );
		control.getContentArea().deploy( grid );
		
		grid = new CGrid( control );
		grid.add( 0, 0, 1, 1, new DefaultSingleCDockable( "c", "Ccccc" ) );
		grid.add( 0, 0, 1, 1, new DefaultSingleCDockable( "d", "Ddddd" ) );
		area.deploy( grid );
		
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setBounds( 20, 20, 400, 400 );
		frame.setVisible( true );
	}
}

[Edit: I also uploaded 1.1.2p8a, at least it fixes the first bug]

Hi Beni,

I could reproduce it with your source code and 1.1.2p8a
First I get this exception after starting the application:

java.lang.ClassNotFoundException: bibliothek.util.workarounds.Java6Workaround
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at bibliothek.util.Workarounds.tryAddWorkaround(Workarounds.java:77)
	at bibliothek.util.Workarounds.<clinit>(Workarounds.java:61)
	at bibliothek.gui.DockController.initiate(DockController.java:408)
	at bibliothek.gui.DockController.<init>(DockController.java:270)
	at bibliothek.gui.DockController.<init>(DockController.java:255)
	at bibliothek.gui.dock.common.intern.CDockController.<init>(CDockController.java:47)
	at bibliothek.gui.dock.common.intern.EfficientControlFactory.createController(EfficientControlFactory.java:49)
	at bibliothek.gui.dock.common.CControl.init(CControl.java:481)
	at bibliothek.gui.dock.common.CControl.<init>(CControl.java:459)
	at bibliothek.gui.dock.common.CControl.<init>(CControl.java:443)
	at bibliothek.gui.dock.common.CControl.<init>(CControl.java:388)
	at bibliothek.gui.dock.common.CControl.<init>(CControl.java:365)
	at test.EditorTest.main(EditorTest.java:13)

then I do the following:

  1. press externalize on Ccccc, Ddddd stack
  2. drag Aaaaa to the external stack
  3. press unexternalize on the stack

The Ccccc is now gone and I get the following exception:

java.lang.IllegalStateException: the parent of 'DefaultCommonDockable[dockable=DefaultSingleCDockable[unique id=single c]]' is not 'bibliothek.gui.dock.StackDockStation@cfb11f' but 'null'
	at bibliothek.gui.dock.DockHierarchyLock.ensureLinked(DockHierarchyLock.java:342)
	at bibliothek.gui.dock.DockHierarchyLock.access$2(DockHierarchyLock.java:340)
	at bibliothek.gui.dock.DockHierarchyLock$Token.release(DockHierarchyLock.java:417)
	at bibliothek.gui.dock.StackDockStation.add(StackDockStation.java:1362)
	at bibliothek.gui.dock.StackDockStation.add(StackDockStation.java:1318)
	at bibliothek.gui.dock.StackDockStation.drop(StackDockStation.java:1156)
	at bibliothek.gui.dock.StackDockStation.drop(StackDockStation.java:1093)
	at bibliothek.gui.dock.station.split.Leaf.insert(Leaf.java:514)
	at bibliothek.gui.dock.station.split.Node.insert(Node.java:613)
	at bibliothek.gui.dock.station.split.Root.insert(Root.java:306)
	at bibliothek.gui.dock.SplitDockStation.drop(SplitDockStation.java:2223)
	at bibliothek.gui.dock.SplitDockStation.drop(SplitDockStation.java:1753)
	at bibliothek.gui.dock.common.mode.station.CSplitDockStationHandle$Normal.setLocation(CSplitDockStationHandle.java:371)
	at bibliothek.gui.dock.facile.mode.DefaultLocationMode.runApply(DefaultLocationMode.java:77)
	at bibliothek.gui.dock.facile.mode.AbstractLocationMode.apply(AbstractLocationMode.java:398)
	at bibliothek.gui.dock.facile.mode.AbstractLocationMode.apply(AbstractLocationMode.java:1)
	at bibliothek.gui.dock.support.mode.ModeManager$4.run(ModeManager.java:700)
	at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:514)
	at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:493)
	at bibliothek.gui.dock.support.mode.ModeManager.apply(ModeManager.java:694)
	at bibliothek.gui.dock.support.mode.ModeManager.apply(ModeManager.java:657)
	at bibliothek.gui.dock.facile.mode.LocationModeManager$6$1.setLocation(LocationModeManager.java:300)
	at bibliothek.gui.dock.common.group.StackGroupMovement.apply(StackGroupMovement.java:99)
	at bibliothek.gui.dock.facile.mode.LocationModeManager$6.run(LocationModeManager.java:294)
	at bibliothek.gui.dock.support.mode.ModeManager$3.run(ModeManager.java:476)
	at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:514)
	at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:474)
	at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:455)
	at bibliothek.gui.dock.facile.mode.LocationModeManager.apply(LocationModeManager.java:289)
	at bibliothek.gui.dock.facile.mode.LocationModeManager$5.run(LocationModeManager.java:265)
	at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:514)
	at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:493)
	at bibliothek.gui.dock.facile.mode.LocationModeManager.setMode(LocationModeManager.java:258)
	at bibliothek.gui.dock.common.intern.AbstractCDockable.setExtendedMode(AbstractCDockable.java:469)
	at bibliothek.gui.dock.common.intern.action.CExtendedModeAction.action(CExtendedModeAction.java:189)
	at bibliothek.gui.dock.common.intern.action.CExtendedModeAction$Action.action(CExtendedModeAction.java:227)
	at bibliothek.gui.dock.themes.basic.action.BasicButtonHandler.triggered(BasicButtonHandler.java:48)
	at bibliothek.gui.dock.themes.basic.action.BasicButtonModel.trigger(BasicButtonModel.java:704)
	at bibliothek.gui.dock.themes.basic.action.BasicButtonModel$Listener.mouseReleased(BasicButtonModel.java:742)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
	at java.awt.Component.processMouseEvent(Component.java:6288)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6053)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4651)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4481)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4481)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
	at java.awt.EventQueue.access$000(EventQueue.java:84)
	at java.awt.EventQueue$1.run(EventQueue.java:602)
	at java.awt.EventQueue$1.run(EventQueue.java:600)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:616)
	at java.awt.EventQueue$2.run(EventQueue.java:614)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Wow, that was a mean bug. There were only a few ways to produce this bug. Basically it was the combination of normalizing the last Dockable in the stack, and the fact that said Dockable was not part of a stack before it was externalized. I’ll upload an update in a “short amount of time”.

About the ClassNotFoundException, that class should be in the same JAR file as the other classes. The code that tries to create the class is only called if you are using a Java 1.6, and works flawlessly on my system. Do you use any kind of special ClassLoader?

Thanks Beni!

About the class not found: in my sandbox workspace I am running with all dockingframes classes
extracted to my workspace and I didn’t notice the docking-frames-core-j6 directory.

I saw you made a change for classnotfound that in the latest release.
I think you can revert that, it was my bad, I was really missing the class (see previous post).
Sorry for late reply!

[QUOTE=mmodelski]I saw you made a change for classnotfound that in the latest release.
I think you can revert that, it was my bad, I was really missing the class (see previous post).
Sorry for late reply![/QUOTE]
Ok, good to know :slight_smile: