This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 135824
Collapse All | Expand All

(-)a/core.windows/src/org/netbeans/core/windows/Constants.java (-1 / +22 lines)
Lines 44-50 Link Here
44
import java.awt.Dimension;
44
import java.awt.Dimension;
45
import javax.swing.JSplitPane;
45
import javax.swing.JSplitPane;
46
import org.netbeans.swing.tabcontrol.TabbedContainer;
46
import org.netbeans.swing.tabcontrol.TabbedContainer;
47
import org.openide.util.Utilities;
48
47
49
/**
48
/**
50
 * Constants in window system.
49
 * Constants in window system.
Lines 109-114 Link Here
109
    /** Name of client property (of Boolean type) which says whether position in model
108
    /** Name of client property (of Boolean type) which says whether position in model
110
     * of the TopComponent which is nonpersistent when closed should be kept. */
109
     * of the TopComponent which is nonpersistent when closed should be kept. */
111
    public static final String KEEP_NON_PERSISTENT_TC_IN_MODEL_WHEN_CLOSED = "KeepNonPersistentTCInModelWhenClosed"; // NOI18N
110
    public static final String KEEP_NON_PERSISTENT_TC_IN_MODEL_WHEN_CLOSED = "KeepNonPersistentTCInModelWhenClosed"; // NOI18N
111
    
112
    /**
113
     * Name of TopComponent's Boolean client property which forces the window system
114
     * to respect TopComponent's preferred size when it is slided-in from left/right/bottom 
115
     * sliding bar when set to Boolean.TRUE. Otherwise the slided-in TopComponent
116
     * will fill the entire width/length of the IDE window (the default behavior).
117
     * This switch is intended for tools/palette windows like e.g. color chooser, 
118
     * tool picker etc.
119
     * 
120
     * @since 6.22
121
     */
122
    public static final String KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN = "netbeans.winsys.tc.keep_preferred_size_when_slided_in"; //NOI18N
123
    
124
    /**
125
     * Name of TopComponent's Boolean client property which instructs the window system to activate
126
     * the given TopComponent at startup time regardless which TopComponent was active at
127
     * shutdown time. So it's usuable for welcome screen-like behavior. 
128
     * If more than one TopComponent has this property set to Boolean.TRUE then
129
     * an arbitrary one will be selected and activated.
130
     * @since 6.22
131
     */
132
    public static final String ACTIVATE_AT_STARTUP = "netbeans.winsys.tc.activate_at_startup"; //NOI18N
112
133
113
    /** Client property to distinguish JWindows/JDialogs used as ui elements
134
    /** Client property to distinguish JWindows/JDialogs used as ui elements
114
     * for separate modes - floating windows.
135
     * for separate modes - floating windows.
(-)a/core.windows/src/org/netbeans/core/windows/PersistenceHandler.java (-1 / +1 lines)
Lines 214-220 Link Here
214
            }
214
            }
215
            //some TopComponents want to be always active when the window system starts (e.g. welcome screen)
215
            //some TopComponents want to be always active when the window system starts (e.g. welcome screen)
216
            for( TopComponent tc : mode.getOpenedTopComponents() ) {
216
            for( TopComponent tc : mode.getOpenedTopComponents() ) {
217
                Object val = tc.getClientProperty( "activateAtStartup" ); //NOI18N
217
                Object val = tc.getClientProperty( Constants.ACTIVATE_AT_STARTUP );
218
                if( null != val && val instanceof Boolean && ((Boolean)val).booleanValue() ) {
218
                if( null != val && val instanceof Boolean && ((Boolean)val).booleanValue() ) {
219
                    activeTopComponentOverride = tc;
219
                    activeTopComponentOverride = tc;
220
                    break;
220
                    break;
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/DesktopImpl.java (-20 / +49 lines)
Lines 78-85 Link Here
78
    private JPanel desktop;
78
    private JPanel desktop;
79
    /** root of slit views */
79
    /** root of slit views */
80
    private ViewElement splitRoot;
80
    private ViewElement splitRoot;
81
    private ViewElement maximizedMode;
82
    private Component splitRootComponent;
83
    private Component viewComponent;
81
    private Component viewComponent;
84
    
82
    
85
    /** slide bars. Lazy initialization, because slide bars are optional. */
83
    /** slide bars. Lazy initialization, because slide bars are optional. */
Lines 134-140 Link Here
134
    
132
    
135
   public void setMaximizedView(ViewElement component) {
133
   public void setMaximizedView(ViewElement component) {
136
134
137
        maximizedMode = component;
138
        if (component.getComponent() != viewComponent) {
135
        if (component.getComponent() != viewComponent) {
139
            setViewComponent(component.getComponent());
136
            setViewComponent(component.getComponent());
140
137
Lines 153-159 Link Here
153
            GridBagConstraints constr = new GridBagConstraints();
150
            GridBagConstraints constr = new GridBagConstraints();
154
            constr.gridx = 1;
151
            constr.gridx = 1;
155
            constr.gridy = 0;
152
            constr.gridy = 0;
156
            constr.fill = constr.BOTH;
153
            constr.fill = GridBagConstraints.BOTH;
157
            constr.weightx = 1;
154
            constr.weightx = 1;
158
            constr.weighty = 1;
155
            constr.weighty = 1;
159
            desktop.add(component, constr);
156
            desktop.add(component, constr);
Lines 308-328 Link Here
308
        editorBounds = new Rectangle(editorLeftTop, editorBounds.getSize());
305
        editorBounds = new Rectangle(editorLeftTop, editorBounds.getSize());
309
        String side = operation.getSide();
306
        String side = operation.getSide();
310
        SlidingView view = findView(side);
307
        SlidingView view = findView(side);
311
        Rectangle splitRootRect = viewComponent.getBounds();
308
        return computeSlideInBounds( viewComponent.getBounds(), side, view.getComponent(), view.getSlideBounds(), view.getSelectedTopComponent() );
309
    }
310
    
311
    //Package private for unit testing
312
    Rectangle computeSlideInBounds( Rectangle splitRootRect, String side, Component slideComponent, Rectangle slideBounds, TopComponent selTc ) {
312
        Rectangle result = new Rectangle();
313
        Rectangle result = new Rectangle();
313
        Rectangle viewRect = view.getComponent().getBounds();
314
        Rectangle viewRect = slideComponent.getBounds();
314
        Dimension viewPreferred = view.getComponent().getPreferredSize();
315
        Dimension viewPreferred = slideComponent.getPreferredSize();
315
        int minThick = MIN_EDITOR_ALIGN_THICK;
316
        int minThick = MIN_EDITOR_ALIGN_THICK;
316
        
317
        
317
        TopComponent tc = view.getSelectedTopComponent();
318
        Dimension tcPreferred = null;
318
        if( null != tc && Boolean.TRUE.equals( tc.getClientProperty( "keepPreferredSizeWhenSlideIn" ) ) ) // NOI18N
319
        boolean keepPreferredSizeWhenSlidedIn = null != selTc 
320
                && Boolean.TRUE.equals( selTc.getClientProperty( Constants.KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN ) );
321
        if( keepPreferredSizeWhenSlidedIn ) {
322
            tcPreferred = selTc.getPreferredSize();
323
            if( null == tcPreferred )
324
                tcPreferred = slideBounds.getSize();
325
        }
326
        
327
        if( keepPreferredSizeWhenSlidedIn )
319
            minThick = 20;
328
            minThick = 20;
320
        
329
        
321
        if (Constants.LEFT.equals(side)) {
330
        if (Constants.LEFT.equals(side)) {
322
            result.x = viewRect.x + Math.max(viewRect.width, viewPreferred.width);
331
            result.x = viewRect.x + Math.max(viewRect.width, viewPreferred.width);
323
            result.y = 0;
332
            result.y = 0;
324
            result.height = splitRootRect.height;
333
            result.height = keepPreferredSizeWhenSlidedIn 
325
            result.width = view.getSlideBounds().width;
334
                    ? tcPreferred.height
335
                    : splitRootRect.height;
336
            result.width = keepPreferredSizeWhenSlidedIn 
337
                    ? tcPreferred.width 
338
                    : slideBounds.width;
326
            if (result.width < minThick) {
339
            if (result.width < minThick) {
327
                result.width = splitRootRect.width / 3;
340
                result.width = splitRootRect.width / 3;
328
            }
341
            }
Lines 332-358 Link Here
332
            }
345
            }
333
        } else if (Constants.RIGHT.equals(side)) {
346
        } else if (Constants.RIGHT.equals(side)) {
334
            int rightLimit = /*layeredPane.getBounds().x  + */ layeredPane.getBounds().width - Math.max(viewRect.width, viewPreferred.width);
347
            int rightLimit = /*layeredPane.getBounds().x  + */ layeredPane.getBounds().width - Math.max(viewRect.width, viewPreferred.width);
335
            result.x = (view.getSlideBounds().width < minThick)
348
            int width = keepPreferredSizeWhenSlidedIn
336
                        ? rightLimit - splitRootRect.width / 3 : rightLimit - view.getSlideBounds().width;
349
                    ? tcPreferred.width
350
                    : slideBounds.width;
351
            result.x = (width < minThick)
352
                        ? rightLimit - splitRootRect.width / 3 : rightLimit - width;
337
            if (result.x < 0) {
353
            if (result.x < 0) {
338
                // make sure we are not bigger than the current window..
354
                // make sure we are not bigger than the current window..
339
                result.x = 0;
355
                result.x = 0;
340
            }
356
            }
341
            result.y = 0;
357
            result.y = 0;
342
            result.height = splitRootRect.height;
358
            result.height = keepPreferredSizeWhenSlidedIn
359
                    ? tcPreferred.height 
360
                    : splitRootRect.height;
343
            result.width = rightLimit - result.x;
361
            result.width = rightLimit - result.x;
344
            
362
            
345
        } else if (Constants.BOTTOM.equals(side)) {
363
        } else if (Constants.BOTTOM.equals(side)) {
346
            int lowerLimit = viewRect.y + viewRect.height - Math.max(viewRect.height, viewPreferred.height);
364
            int lowerLimit = viewRect.y + viewRect.height - Math.max(viewRect.height, viewPreferred.height);
365
            int height = keepPreferredSizeWhenSlidedIn 
366
                    ? tcPreferred.height
367
                    : slideBounds.height;
347
            result.x = splitRootRect.x;
368
            result.x = splitRootRect.x;
348
            result.y = (view.getSlideBounds().height < minThick)
369
            result.y = (height < minThick)
349
                        ? lowerLimit - splitRootRect.height / 3 : lowerLimit - view.getSlideBounds().height;
370
                        ? lowerLimit - splitRootRect.height / 3 : lowerLimit - height;
350
            if (result.y < 0) {
371
            if (result.y < 0) {
351
                // make sure we are not bigger than the current window..
372
                // make sure we are not bigger than the current window..
352
                result.y = 0;
373
                result.y = 0;
353
            }
374
            }
354
            result.height = lowerLimit - result.y;
375
            result.height = lowerLimit - result.y;
355
            result.width = splitRootRect.width;
376
            result.width = keepPreferredSizeWhenSlidedIn
377
                    ? tcPreferred.width 
378
                    : splitRootRect.width;
356
        }
379
        }
357
        return result;
380
        return result;
358
    }
381
    }
Lines 436-448 Link Here
436
                // #43865, #49320 - sliding wiew or viewcomponent could be removed by closing
459
                // #43865, #49320 - sliding wiew or viewcomponent could be removed by closing
437
                if (curView != null && viewComponent != null) {
460
                if (curView != null && viewComponent != null) {
438
                    Component slidedComp = curSlideIn.getComponent();
461
                    Component slidedComp = curSlideIn.getComponent();
462
                    TopComponent tc = curView.getSelectedTopComponent();
463
                    boolean keepPreferredSizeWhenSlidedIn = null != tc 
464
                            && Boolean.TRUE.equals( tc.getClientProperty( Constants.KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN ) );
439
                    Rectangle result = slidedComp.getBounds();
465
                    Rectangle result = slidedComp.getBounds();
440
                    Rectangle viewRect = curView.getComponent().getBounds();
466
                    Rectangle viewRect = curView.getComponent().getBounds();
441
                    Dimension viewPrefSize = curView.getComponent().getPreferredSize();
467
                    Dimension viewPrefSize = curView.getComponent().getPreferredSize();
442
                    Rectangle splitRootRect = viewComponent.getBounds();
468
                    Rectangle splitRootRect = viewComponent.getBounds();
443
469
444
                    if (Constants.LEFT.equals(side)) {
470
                    if (Constants.LEFT.equals(side)) {
445
                        result.height = splitRootRect.height;
471
                        if( !keepPreferredSizeWhenSlidedIn )
472
                            result.height = splitRootRect.height;
446
                        if (lastSize != null && !lastSize.equals(size)) {
473
                        if (lastSize != null && !lastSize.equals(size)) {
447
                            int wid = curView.getSlideBounds().width;
474
                            int wid = curView.getSlideBounds().width;
448
                            if (wid > (size.width - viewRect.width)) {
475
                            if (wid > (size.width - viewRect.width)) {
Lines 453-459 Link Here
453
                            }
480
                            }
454
                        }
481
                        }
455
                    } else if (Constants.RIGHT.equals(side)) {
482
                    } else if (Constants.RIGHT.equals(side)) {
456
                        result.height = splitRootRect.height;
483
                        if( !keepPreferredSizeWhenSlidedIn )
484
                            result.height = splitRootRect.height;
457
                        if (lastSize != null && !lastSize.equals(size)) {
485
                        if (lastSize != null && !lastSize.equals(size)) {
458
                            int avail = size.width - Math.max(viewRect.width, viewPrefSize.width);
486
                            int avail = size.width - Math.max(viewRect.width, viewPrefSize.width);
459
                            int wid = curView.getSlideBounds().width;
487
                            int wid = curView.getSlideBounds().width;
Lines 466-472 Link Here
466
                            }
494
                            }
467
                        }
495
                        }
468
                    } else if (Constants.BOTTOM.equals(side)) {
496
                    } else if (Constants.BOTTOM.equals(side)) {
469
                        result.width = splitRootRect.width;
497
                        if( !keepPreferredSizeWhenSlidedIn )
498
                            result.width = splitRootRect.width;
470
                        if (lastSize != null && !lastSize.equals(size)) {
499
                        if (lastSize != null && !lastSize.equals(size)) {
471
                            int avail = size.height - Math.max(viewRect.height, viewPrefSize.height);
500
                            int avail = size.height - Math.max(viewRect.height, viewPrefSize.height);
472
                            int hei = viewRect.height;
501
                            int hei = viewRect.height;
(-)a/openide.windows/apichanges.xml (+18 lines)
Lines 47-52 Link Here
47
<apidef name="winsys">Window System API</apidef>
47
<apidef name="winsys">Window System API</apidef>
48
</apidefs>
48
</apidefs>
49
<changes>
49
<changes>
50
51
<change id="keep_preferred_size_when_slided_in">
52
    <api name="winsys"/>
53
    <summary>Changed behavior of TopComponent.close() and TopComponentGroup.close() for non persistent TopComponent</summary>
54
    <version major="6" minor="22"/>
55
    <date day="27" month="5" year="2008"/>
56
    <author login="saubrecht"/>
57
    <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
58
    <description>
59
	Added TopComponent client property netbeans.winsys.tc.keep_preferred_size_when_slided_in which forces the window system
60
        to respect TopComponent's preferred size when it is slided-in from left/right/bottom 
61
        sliding bar when set to Boolean.TRUE. Otherwise the slided-in TopComponent
62
        will fill the entire width/length of the IDE window (the default behavior).
63
        This switch is intended for tools/palette windows like e.g. color chooser, 
64
        tool picker etc.
65
    </description>
66
    <issue number="135318"/>
67
</change>
50
68
51
<change id="KeepNonPersistentTCInModelWhenClosed">
69
<change id="KeepNonPersistentTCInModelWhenClosed">
52
    <api name="winsys"/>
70
    <api name="winsys"/>
(-)a/openide.windows/arch.xml (-26 / +24 lines)
Lines 513-544 Link Here
513
-->
513
-->
514
<answer id="exec-component">
514
<answer id="exec-component">
515
Yes. Component can control its persistence and way how they are displayed in container.
515
Yes. Component can control its persistence and way how they are displayed in container.
516
<api type="export" group="property" name="PersistenceType" category="deprecated">
517
    Valid values are "Never", "OnlyOpened". Default is "" (empty string) and means always persistent.
518
    "Never" means that TopComponent is not persistent at all. It lives only during IDE run.
519
    "OnlyOpened" means that TopComponent is serialized only when it is opened. If it is closed
520
    instance is lost.
521
    Default behaviour is that TopComponent is serialized always regardless it is opened or
522
    closed.
523
    It is client property of TopComponent. Usage example: To disable persistence of TopComponent
524
    use <code>putClientProperty("PersistenceType","Never");</code> in initialization code of TopComponent
525
    eg. in constructor.
526
    Usage of this client property is deprecated. Use API method <code>TopComponent.getPersistenceType()</code>
527
    instead.
528
</api>
529
<api type="export" group="property" name="SlidingName" category="private">
530
    Valid value is any String value representing displayable title of TopComponent in
531
    sliding mode. Title is shown on buttons on sides of main window for TopComponents that
532
    are currently hidden in sliding state. 
533
    This property has no effect on regular display names of TopComponents which are shown in
534
    captions of windows/tabs in the window system.
535
    It is client property of TopComponent. Usage example: To provide different, preferably
536
    shorter and non changing name for sliding title of your TopComponent subclass, 
537
    use <code>putClientProperty("SlidingName","your sliding title");</code> in initialization code of TopComponent
538
    eg. in constructor.
539
    Note that in next releases usage of this client property will be removed and replaced 
540
    by API, see issue #55955 in Issuezilla on www.netbeans.org.
541
</api>
542
<api type="export" group="property" name="KeepNonPersistentTCInModelWhenClosed" category="private">
516
<api type="export" group="property" name="KeepNonPersistentTCInModelWhenClosed" category="private">
543
    Client property "KeepNonPersistentTCInModelWhenClosed" of TopComponent controls behavior of winsys
517
    Client property "KeepNonPersistentTCInModelWhenClosed" of TopComponent controls behavior of winsys
544
    when TopComponent with persistence type "Never" or "OnlyOpened" is closed. As some TopComponent wants
518
    when TopComponent with persistence type "Never" or "OnlyOpened" is closed. As some TopComponent wants
Lines 549-554 Link Here
549
    If property is set (to Boolean.TRUE) then TopComponent is kept in model. It means that
523
    If property is set (to Boolean.TRUE) then TopComponent is kept in model. It means that
550
    client must explicitly set this client property to get behavior requested by issue #101700.
524
    client must explicitly set this client property to get behavior requested by issue #101700.
551
</api>
525
</api>
526
527
<api type="export" group="property" name="netbeans.winsys.tc.activate_at_startup" category="private">
528
     Name of TopComponent's Boolean client property which instructs the window system to activate
529
     the given TopComponent at startup time regardless which TopComponent was active at
530
     shutdown time. So it's usuable for welcome screen-like behavior. 
531
     If more than one TopComponent has this property set to Boolean.TRUE then
532
     an arbitrary one will be selected and activated.
533
</api>
534
535
<api type="export" group="property" name="TopComponentAllowDockAnywhere" category="private">
536
    Name of client property (of Boolean type) which says whether the TopComponent is allowed
537
    to be docked anywhere (even crossing view-editor border).
538
</api>
539
540
541
<api type="export" group="property" name="netbeans.winsys.tc.keep_preferred_size_when_slided_in" category="stable">
542
     Name of TopComponent's Boolean client property which forces the window system
543
     to respect TopComponent's preferred size when it is slided-in from left/right/bottom 
544
     sliding bar when set to Boolean.TRUE. Otherwise the slided-in TopComponent
545
     will fill the entire width/length of the IDE window (the default behavior).
546
     This switch is intended for tools/palette windows like e.g. color chooser, 
547
     tool picker etc.
548
</api>
549
552
550
553
<!--<api group="property" name="NamingType" type="export" category="private">
551
<!--<api group="property" name="NamingType" type="export" category="private">
554
    Valid values are "BothOnlyCompName", "SDIOnlyCompName", "MDIOnlyCompName". 
552
    Valid values are "BothOnlyCompName", "SDIOnlyCompName", "MDIOnlyCompName". 
(-)a/openide.windows/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.windows
2
OpenIDE-Module: org.openide.windows
3
OpenIDE-Module-Specification-Version: 6.21
3
OpenIDE-Module-Specification-Version: 6.22
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
5
AutoUpdate-Essential-Module: true
5
AutoUpdate-Essential-Module: true
6
6

Return to bug 135824