Resize policy question

Hi,

First of all big thank you for Docking Framework!

My qeustion is following:

I’m using Eclipse Theme (library version 1.1.2p12 commons+core) - but generally speaking this applies to FLAT theme as well (other were not tested). Initially I’m adding couple of dialogs as DefaultMultipleCDockable. Then I’m dragging them apart and try to drag vertical splitter to the left or to the right. This is where I’m getting some problems. I’t impossible to shrink dialog in way that it’s title will be partially invisible/truncated. Or if I have some complex dialog inside CDockable then minimum size inside it prevents dialog from shrinking.

But if user adds third (let’s say) MultipleCDockable under A or B, then such 2Tabbed CDockable can be shrinked as much as needed.

I’d like to allow such “shrinkage” for single MultipleCDockable as well. Is it possible to override it via property or I need to create extension of default layout?

Best regards,
An

P.S. I’ve tried technique described in Post#14: http://forum.byte-welt.net/threads/3865-SplitDockStation-resize-bug-in-Eclipse-theme?highlight=resize - it made no difference.

I guess the easiest solution would be to ensure that your Components have a small “minimum” size. But if you want to implement your own logic to decide which values for the “vertical splitter” are valid, and which are not:


import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.SplitDockStation.Orientation;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.intern.station.CLockedResizeLayoutManager;
import bibliothek.gui.dock.common.theme.ThemeMap;
import bibliothek.gui.dock.station.split.DefaultSplitLayoutManager;

public class NoSplitValidation {
	public static void main( String[] args ) {
		JFrame frame = new JFrame();
		CControl control = new CControl(frame);
		control.setTheme(ThemeMap.KEY_FLAT_THEME );

		// remove this line of code and you will not be able to resize the Dockables because their minimum size is just too big.
		control.putProperty( SplitDockStation.LAYOUT_MANAGER, new NoValidatingLayoutManager( control ) );
		
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setBounds( 20, 20, 800, 800 );
		
		CGrid grid = new CGrid( control );
		grid.add( 0, 0, 1, 1, new DefaultSingleCDockable( "a", "AAAAAAA", comp() ) );
		grid.add( 1, 0, 1, 1, new DefaultSingleCDockable( "b", "BBBBBBB", comp() ) );
		frame.add( control.getContentArea() );
		control.getContentArea().deploy( grid );
		
		frame.setVisible( true );
	}
	
	
	
	private static JPanel comp(){
		return new JPanel(){
			@Override
			public Dimension getMinimumSize() {
				return new Dimension( 400, 400 );
			}
		};
	}
	
	private static class NoValidatingLayoutManager extends CLockedResizeLayoutManager{
		// We need to subclass CLockedResizeLayoutManager, and then override its "delegate" property. 
		// The delegate property references the algorithm that will validate whehter a divider is legal or not.
		public NoValidatingLayoutManager(CControl control){
			super(new DefaultSplitLayoutManager(){
				@Override
				protected double validateDivider( SplitDockStation station, double divider, Dimension minimumLeft, Dimension minimumRight, Orientation orientation, double width, double height ) {
					// we just allow any user input
					return divider;
				}
			});
			setControl( control );
		}
	}
}

Hi Beni,

First of all - thank you for your answer.

Solution works for FLAT_THEME, but not for ECLIPSE_THEME… In case of eclipse theme still title width dictate minimum width of CDockable. Again if there are several dockables stacked in on one side of A|B setup then such stack does not respects current top-most dockable title width…

Can you give me some hints on where to look for fix in the eclipse_theme ?

Best regards,
An

I’ll have to dig through some code, you’ll get an answer but probably not before the weekend.

Ok, so far what I see is:

In case Eclipse theme is used, then for getting minimum size framework calls TabComponentLayoutManager.minimumLayoutSize(parent). Looking at line 305 we see:
label.getMinimumSize(), this minimum size is later widened using action buttons minimum sizes.

In case Flat theme is used then neither of:
StackTabListLayout,
TabComponentLayoutManager is invoked to get minimum size…

Digging further…

Best regards,
An

*** Edit ***

In case of FLAT theme “LayoutMngr.minimumLayoutSize(…)” is not used, because Container.java have non null ‘minSize’ equal to Dimension(width=20,height=30) (see Container:minimumSize() line 1659 (I’m using IBM jdk, in SUN this can be different…), thus this value is returned and LayoutManager is not called to find out component minimum size.

Now the question is where this 20,30 minimum size is setted…

I’ve checked stacktraces and seems EclipseTheme does not uses NoValidatingLayoutManager setted via SplitDockStation.LAYOUT_MANAGER property.
For now solved problem for eclipse theme via hack: clontrol.putProperty(TabPane.LAYOUT_MANAGER, new RowLayout()); So now basically setting minimum size is impossible…

Sorry for my late response, I had a terrible cold and was in my bed for the past couple of days :mad:

Now I took the old example application, changed the theme, and added another Dockable. This is the result:

The theme and the “NoValidatingLayoutManager” are on two different levels, the work in parallel, neither depends on the other:
[ul]
[li]The theme is used to paint SplitDockStations (the center are on the frame)
[/li][li]The NoValidatingLayoutManager decides about the size and position of the content of the SplitDockStations
[/li][/ul]

I guess you tried to make a floating Dockable - a Dockable that hovers over the mainframe? The size and position of that window is calculated by the “BoundaryRestriction” interface. You can exchange and modify that restriction. You will need the newest version of the framework, because I added the “getMinimumSize” method only a couple of minutes ago.

	protected Dimension getMinimumSize( ScreenDockWindow window ){
		// I would advice not to use 0/0 here, or the user won't see the window...
		return new Dimension( 100, 10 );
	}
} );```