Externalised Window predefined size

I’m trying to have a small dockable open up to a larger size when externalised. The default behaviour is to be externalised with the same size as when the dock is not externalised. To do so, I tried to extend the CExternalizeAction like so:


class EnlargeWindowAction extends CExternalizeAction {
		public EnlargeWindowAction(CControl ccontrol) {
			super(ccontrol);
			myDock.setResizeRequest(new Dimension(100, 100), true);
		}
	}

and use it like so:


myDock.putAction(CDockable.ACTION_KEY_EXTERNALIZE,
				new EnlargeWindowAction(control1));

To my surprise, the dock no longer externalized!? Can you give me some pointer and explain where my reasoning went wrong?

Was ist CExternalizeAction? Welche Lib ist das?

@Morfes
I can’t see why your dockables should not react on the action. In my test-application they work without complaint. Perhaps you have more than one CControl and they got mixed up?

@Guest: CExternalizeAction is part of the Common-library.


import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JFrame;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.action.predefined.CExternalizeAction;
import bibliothek.gui.dock.common.intern.CDockable;

public class Dock2 {
	private static class EnlargeWindowAction extends CExternalizeAction {
		public EnlargeWindowAction( CControl ccontrol ){
			super( ccontrol );
		}
		
		@Override
		public void action( CDockable dockable ){
			super.action( dockable );
			if( dockable instanceof DefaultSingleCDockable ){
				((DefaultSingleCDockable)dockable).setResizeRequest( new Dimension( 100, 100 ), true );
			}
		}
	}

	public static void main( String[] args ){
		JFrame frame = new JFrame( "MCMS" );
		CControl control = new CControl( frame );

		frame.add( control.getContentArea() );

		// Create CDockable
		DefaultSingleCDockable a = createDockable( "a", Color.CYAN );
		a.putAction( CDockable.ACTION_KEY_EXTERNALIZE, new EnlargeWindowAction( control ));
		
		DefaultSingleCDockable b = createDockable( "b", Color.BLUE );
		b.putAction( CDockable.ACTION_KEY_EXTERNALIZE, new EnlargeWindowAction( control ));
		
		DefaultSingleCDockable c = createDockable( "c", Color.GREEN );
		c.putAction( CDockable.ACTION_KEY_EXTERNALIZE, new EnlargeWindowAction( control ));

		// Place CDockables
		CGrid grid = new CGrid( control );
		grid.add( 0, 0, 1, 3, a );
		grid.add( 1, 0, 3, 2, b );
		grid.add( 1, 1, 3, 1, c );
		control.getContentArea().deploy( grid );

		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setBounds( 20, 20, 500, 500 );
		frame.setVisible( true );
	}

	public static DefaultSingleCDockable createDockable( String title, Object ingore ){
		return new DefaultSingleCDockable( title, title );
	}
}

Indeed I have more then one controller but I was finally able to figure what was messing with my code… I was seting

 myDock.setMinimizable(false);```
and that, for some reason, messed things up. I replaced that code with 
```myDock.putAction(CDockable.ACTION_KEY_MAXIMIZE, CBlank.BLANK);
myDock.putAction(CDockable.ACTION_KEY_MINIMIZE, CBlank.BLANK);```
and now all works like a charm :D. Thanks for your speedy help, I really appreciated :D

WTF? That is pretty bad bug you found there! Of course setting maximizeable/minimizeable to false should not have an effect on the other settings.

[OMFG. And the serious bug is caused by the noobish failure of forgetting a “break” in a switch-case statement. I’m now going to the cellar and do penance…]

Careful now with that penance… because now that the externalise works, I noticed something else. Even thou I set the dock to not be maximizable or minimizable, if I do a double click in the title bar, it does the maximize behaviour, and the minimize button appears :s

That is not so wrong: you just replaced the look of the button, but the abbility to change remains (and you should see the “normalize”-button, not the “minimize”-button).

I’ll upload a new version of the library during weekend (can’t compile it at the place I am now). Then all problems will be gone.

Cool, thanks a million :smiley:
(and yes, its the normalize button :stuck_out_tongue: )