Restoring minimized to external

Hi Beni,

I perform the following actions in the Size & Color example:

  1. Start the application with all dockables internal
  2. Externalize a dockable
  3. Minimize the dockable
  4. Normalize the dockable
    The dockable goes back to its original position in the main window.
    Is it possible to make it go back to its previous position - external?
    Do I need to implement a custom Minimizer like in the Help example?

kind regards,
Maciej Modelski

You could replace the “normalize” button with another button that looks the same, but has different behavior. Like in this example:


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.CNormalizeAction;
import bibliothek.gui.dock.common.intern.CDockable;
import bibliothek.gui.dock.common.mode.CLocationMode;
import bibliothek.gui.dock.common.mode.ExtendedMode;
import bibliothek.gui.dock.facile.mode.DefaultLocationModeActionProvider;
import bibliothek.gui.dock.facile.mode.LocationModeActionProvider;

public class SpecialButton {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(20, 20, 400,300);
		
		CControl control = new CControl(frame);
		frame.add(control.getContentArea());
		LocationModeActionProvider customNormalizeAction = new DefaultLocationModeActionProvider(new CustomNormalizeAction(control));
		control.getLocationManager().getNormalMode().setActionProvider(customNormalizeAction);
		
		CGrid grid = new CGrid(control);
		grid.add(0, 0, 1, 1, new DefaultSingleCDockable("a", "Aaa"));
		grid.add(0, 1, 1, 1, new DefaultSingleCDockable("b", "Bbb"));
		grid.add(1, 0, 1, 2, new DefaultSingleCDockable("c", "Ccc"));
		control.getContentArea().deploy(grid);
		
		frame.setVisible(true);
	}
	
	private static class CustomNormalizeAction extends CNormalizeAction{
		public CustomNormalizeAction(CControl control) {
			super(control);
		}

		@Override
		public void action(CDockable dockable) {
			if( dockable.getExtendedMode() == ExtendedMode.MINIMIZED ){
				CControl control = dockable.getControl();
				CLocationMode previous = control.getLocationManager().getPreviousMode(dockable.intern());
				if( previous != null && previous.getExtendedMode() != ExtendedMode.MINIMIZED ){
					dockable.setExtendedMode(previous.getExtendedMode());
				}
				else{
					super.action(dockable);
				}
			}
			else{
				super.action(dockable);
			}
		}
	}
}

Thanks Beni, works as expected! :slight_smile: