--- a/core.windows/src/org/netbeans/core/windows/Constants.java Thu May 15 07:27:08 2008 +0200 +++ a/core.windows/src/org/netbeans/core/windows/Constants.java Mon May 26 17:06:19 2008 +0200 @@ -44,7 +44,6 @@ import java.awt.Dimension; import javax.swing.JSplitPane; import org.netbeans.swing.tabcontrol.TabbedContainer; -import org.openide.util.Utilities; /** * Constants in window system. @@ -109,6 +108,28 @@ /** Name of client property (of Boolean type) which says whether position in model * of the TopComponent which is nonpersistent when closed should be kept. */ public static final String KEEP_NON_PERSISTENT_TC_IN_MODEL_WHEN_CLOSED = "KeepNonPersistentTCInModelWhenClosed"; // NOI18N + + /** + * Name of TopComponent's Boolean client property which forces the window system + * to respect TopComponent's preferred size when it is slided-in from left/right/bottom + * sliding bar when set to Boolean.TRUE. Otherwise the slided-in TopComponent + * will fill the entire width/length of the IDE window (the default behavior). + * This switch is intended for tools/palette windows like e.g. color chooser, + * tool picker etc. + * + * @since 6.22 + */ + public static final String KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN = "netbeans.winsys.tc.keep_preferred_size_when_slided_in"; //NOI18N + + /** + * Name of TopComponent's Boolean client property which instructs the window system to activate + * the given TopComponent at startup time regardless which TopComponent was active at + * shutdown time. So it's usuable for welcome screen-like behavior. + * If more than one TopComponent has this property set to Boolean.TRUE then + * an arbitrary one will be selected and activated. + * @since 6.22 + */ + public static final String ACTIVATE_AT_STARTUP = "netbeans.winsys.tc.activate_at_startup"; //NOI18N /** Client property to distinguish JWindows/JDialogs used as ui elements * for separate modes - floating windows. --- a/core.windows/src/org/netbeans/core/windows/PersistenceHandler.java Thu May 15 07:27:08 2008 +0200 +++ a/core.windows/src/org/netbeans/core/windows/PersistenceHandler.java Mon May 26 17:06:19 2008 +0200 @@ -214,7 +214,7 @@ } //some TopComponents want to be always active when the window system starts (e.g. welcome screen) for( TopComponent tc : mode.getOpenedTopComponents() ) { - Object val = tc.getClientProperty( "activateAtStartup" ); //NOI18N + Object val = tc.getClientProperty( Constants.ACTIVATE_AT_STARTUP ); if( null != val && val instanceof Boolean && ((Boolean)val).booleanValue() ) { activeTopComponentOverride = tc; break; --- a/core.windows/src/org/netbeans/core/windows/view/ui/DesktopImpl.java Thu May 15 07:27:08 2008 +0200 +++ a/core.windows/src/org/netbeans/core/windows/view/ui/DesktopImpl.java Mon May 26 17:06:19 2008 +0200 @@ -78,8 +78,6 @@ private JPanel desktop; /** root of slit views */ private ViewElement splitRoot; - private ViewElement maximizedMode; - private Component splitRootComponent; private Component viewComponent; /** slide bars. Lazy initialization, because slide bars are optional. */ @@ -134,7 +132,6 @@ public void setMaximizedView(ViewElement component) { - maximizedMode = component; if (component.getComponent() != viewComponent) { setViewComponent(component.getComponent()); @@ -153,7 +150,7 @@ GridBagConstraints constr = new GridBagConstraints(); constr.gridx = 1; constr.gridy = 0; - constr.fill = constr.BOTH; + constr.fill = GridBagConstraints.BOTH; constr.weightx = 1; constr.weighty = 1; desktop.add(component, constr); @@ -308,21 +305,37 @@ editorBounds = new Rectangle(editorLeftTop, editorBounds.getSize()); String side = operation.getSide(); SlidingView view = findView(side); - Rectangle splitRootRect = viewComponent.getBounds(); + return computeSlideInBounds( viewComponent.getBounds(), side, view.getComponent(), view.getSlideBounds(), view.getSelectedTopComponent() ); + } + + //Package private for unit testing + Rectangle computeSlideInBounds( Rectangle splitRootRect, String side, Component slideComponent, Rectangle slideBounds, TopComponent selTc ) { Rectangle result = new Rectangle(); - Rectangle viewRect = view.getComponent().getBounds(); - Dimension viewPreferred = view.getComponent().getPreferredSize(); + Rectangle viewRect = slideComponent.getBounds(); + Dimension viewPreferred = slideComponent.getPreferredSize(); int minThick = MIN_EDITOR_ALIGN_THICK; - TopComponent tc = view.getSelectedTopComponent(); - if( null != tc && Boolean.TRUE.equals( tc.getClientProperty( "keepPreferredSizeWhenSlideIn" ) ) ) // NOI18N + Dimension tcPreferred = null; + boolean keepPreferredSizeWhenSlidedIn = null != selTc + && Boolean.TRUE.equals( selTc.getClientProperty( Constants.KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN ) ); + if( keepPreferredSizeWhenSlidedIn ) { + tcPreferred = selTc.getPreferredSize(); + if( null == tcPreferred ) + tcPreferred = slideBounds.getSize(); + } + + if( keepPreferredSizeWhenSlidedIn ) minThick = 20; if (Constants.LEFT.equals(side)) { result.x = viewRect.x + Math.max(viewRect.width, viewPreferred.width); result.y = 0; - result.height = splitRootRect.height; - result.width = view.getSlideBounds().width; + result.height = keepPreferredSizeWhenSlidedIn + ? tcPreferred.height + : splitRootRect.height; + result.width = keepPreferredSizeWhenSlidedIn + ? tcPreferred.width + : slideBounds.width; if (result.width < minThick) { result.width = splitRootRect.width / 3; } @@ -332,27 +345,37 @@ } } else if (Constants.RIGHT.equals(side)) { int rightLimit = /*layeredPane.getBounds().x + */ layeredPane.getBounds().width - Math.max(viewRect.width, viewPreferred.width); - result.x = (view.getSlideBounds().width < minThick) - ? rightLimit - splitRootRect.width / 3 : rightLimit - view.getSlideBounds().width; + int width = keepPreferredSizeWhenSlidedIn + ? tcPreferred.width + : slideBounds.width; + result.x = (width < minThick) + ? rightLimit - splitRootRect.width / 3 : rightLimit - width; if (result.x < 0) { // make sure we are not bigger than the current window.. result.x = 0; } result.y = 0; - result.height = splitRootRect.height; + result.height = keepPreferredSizeWhenSlidedIn + ? tcPreferred.height + : splitRootRect.height; result.width = rightLimit - result.x; } else if (Constants.BOTTOM.equals(side)) { int lowerLimit = viewRect.y + viewRect.height - Math.max(viewRect.height, viewPreferred.height); + int height = keepPreferredSizeWhenSlidedIn + ? tcPreferred.height + : slideBounds.height; result.x = splitRootRect.x; - result.y = (view.getSlideBounds().height < minThick) - ? lowerLimit - splitRootRect.height / 3 : lowerLimit - view.getSlideBounds().height; + result.y = (height < minThick) + ? lowerLimit - splitRootRect.height / 3 : lowerLimit - height; if (result.y < 0) { // make sure we are not bigger than the current window.. result.y = 0; } result.height = lowerLimit - result.y; - result.width = splitRootRect.width; + result.width = keepPreferredSizeWhenSlidedIn + ? tcPreferred.width + : splitRootRect.width; } return result; } @@ -436,13 +459,17 @@ // #43865, #49320 - sliding wiew or viewcomponent could be removed by closing if (curView != null && viewComponent != null) { Component slidedComp = curSlideIn.getComponent(); + TopComponent tc = curView.getSelectedTopComponent(); + boolean keepPreferredSizeWhenSlidedIn = null != tc + && Boolean.TRUE.equals( tc.getClientProperty( Constants.KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN ) ); Rectangle result = slidedComp.getBounds(); Rectangle viewRect = curView.getComponent().getBounds(); Dimension viewPrefSize = curView.getComponent().getPreferredSize(); Rectangle splitRootRect = viewComponent.getBounds(); if (Constants.LEFT.equals(side)) { - result.height = splitRootRect.height; + if( !keepPreferredSizeWhenSlidedIn ) + result.height = splitRootRect.height; if (lastSize != null && !lastSize.equals(size)) { int wid = curView.getSlideBounds().width; if (wid > (size.width - viewRect.width)) { @@ -453,7 +480,8 @@ } } } else if (Constants.RIGHT.equals(side)) { - result.height = splitRootRect.height; + if( !keepPreferredSizeWhenSlidedIn ) + result.height = splitRootRect.height; if (lastSize != null && !lastSize.equals(size)) { int avail = size.width - Math.max(viewRect.width, viewPrefSize.width); int wid = curView.getSlideBounds().width; @@ -466,7 +494,8 @@ } } } else if (Constants.BOTTOM.equals(side)) { - result.width = splitRootRect.width; + if( !keepPreferredSizeWhenSlidedIn ) + result.width = splitRootRect.width; if (lastSize != null && !lastSize.equals(size)) { int avail = size.height - Math.max(viewRect.height, viewPrefSize.height); int hei = viewRect.height; --- a/openide.windows/apichanges.xml Thu May 15 07:27:08 2008 +0200 +++ a/openide.windows/apichanges.xml Mon May 26 17:06:19 2008 +0200 @@ -47,6 +47,24 @@ Window System API + + + + Changed behavior of TopComponent.close() and TopComponentGroup.close() for non persistent TopComponent + + + + + + Added TopComponent client property netbeans.winsys.tc.keep_preferred_size_when_slided_in which forces the window system + to respect TopComponent's preferred size when it is slided-in from left/right/bottom + sliding bar when set to Boolean.TRUE. Otherwise the slided-in TopComponent + will fill the entire width/length of the IDE window (the default behavior). + This switch is intended for tools/palette windows like e.g. color chooser, + tool picker etc. + + + --- a/openide.windows/arch.xml Thu May 15 07:27:08 2008 +0200 +++ a/openide.windows/arch.xml Mon May 26 17:06:19 2008 +0200 @@ -513,32 +513,6 @@ --> Yes. Component can control its persistence and way how they are displayed in container. - - Valid values are "Never", "OnlyOpened". Default is "" (empty string) and means always persistent. - "Never" means that TopComponent is not persistent at all. It lives only during IDE run. - "OnlyOpened" means that TopComponent is serialized only when it is opened. If it is closed - instance is lost. - Default behaviour is that TopComponent is serialized always regardless it is opened or - closed. - It is client property of TopComponent. Usage example: To disable persistence of TopComponent - use putClientProperty("PersistenceType","Never"); in initialization code of TopComponent - eg. in constructor. - Usage of this client property is deprecated. Use API method TopComponent.getPersistenceType() - instead. - - - Valid value is any String value representing displayable title of TopComponent in - sliding mode. Title is shown on buttons on sides of main window for TopComponents that - are currently hidden in sliding state. - This property has no effect on regular display names of TopComponents which are shown in - captions of windows/tabs in the window system. - It is client property of TopComponent. Usage example: To provide different, preferably - shorter and non changing name for sliding title of your TopComponent subclass, - use putClientProperty("SlidingName","your sliding title"); in initialization code of TopComponent - eg. in constructor. - Note that in next releases usage of this client property will be removed and replaced - by API, see issue #55955 in Issuezilla on www.netbeans.org. - Client property "KeepNonPersistentTCInModelWhenClosed" of TopComponent controls behavior of winsys when TopComponent with persistence type "Never" or "OnlyOpened" is closed. As some TopComponent wants @@ -549,6 +523,30 @@ If property is set (to Boolean.TRUE) then TopComponent is kept in model. It means that client must explicitly set this client property to get behavior requested by issue #101700. + + + Name of TopComponent's Boolean client property which instructs the window system to activate + the given TopComponent at startup time regardless which TopComponent was active at + shutdown time. So it's usuable for welcome screen-like behavior. + If more than one TopComponent has this property set to Boolean.TRUE then + an arbitrary one will be selected and activated. + + + + Name of client property (of Boolean type) which says whether the TopComponent is allowed + to be docked anywhere (even crossing view-editor border). + + + + + Name of TopComponent's Boolean client property which forces the window system + to respect TopComponent's preferred size when it is slided-in from left/right/bottom + sliding bar when set to Boolean.TRUE. Otherwise the slided-in TopComponent + will fill the entire width/length of the IDE window (the default behavior). + This switch is intended for tools/palette windows like e.g. color chooser, + tool picker etc. + +