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; |