|
Lines 10-15
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.ui.internal.presentations; |
11 |
package org.eclipse.ui.internal.presentations; |
| 12 |
|
12 |
|
|
|
13 |
import java.util.ArrayList; |
| 14 |
import java.util.List; |
| 15 |
|
| 13 |
import org.eclipse.jface.action.IMenuManager; |
16 |
import org.eclipse.jface.action.IMenuManager; |
| 14 |
import org.eclipse.jface.action.MenuManager; |
17 |
import org.eclipse.jface.action.MenuManager; |
| 15 |
import org.eclipse.jface.resource.FontRegistry; |
18 |
import org.eclipse.jface.resource.FontRegistry; |
|
Lines 24-39
Link Here
|
| 24 |
import org.eclipse.swt.events.MouseAdapter; |
27 |
import org.eclipse.swt.events.MouseAdapter; |
| 25 |
import org.eclipse.swt.events.MouseEvent; |
28 |
import org.eclipse.swt.events.MouseEvent; |
| 26 |
import org.eclipse.swt.events.MouseListener; |
29 |
import org.eclipse.swt.events.MouseListener; |
|
|
30 |
import org.eclipse.swt.events.SelectionAdapter; |
| 31 |
import org.eclipse.swt.events.SelectionEvent; |
| 27 |
import org.eclipse.swt.graphics.Color; |
32 |
import org.eclipse.swt.graphics.Color; |
|
|
33 |
import org.eclipse.swt.graphics.Image; |
| 28 |
import org.eclipse.swt.graphics.Point; |
34 |
import org.eclipse.swt.graphics.Point; |
| 29 |
import org.eclipse.swt.graphics.Rectangle; |
35 |
import org.eclipse.swt.graphics.Rectangle; |
| 30 |
import org.eclipse.swt.widgets.Control; |
36 |
import org.eclipse.swt.widgets.Control; |
|
|
37 |
import org.eclipse.swt.widgets.Display; |
| 31 |
import org.eclipse.swt.widgets.Event; |
38 |
import org.eclipse.swt.widgets.Event; |
| 32 |
import org.eclipse.swt.widgets.Listener; |
39 |
import org.eclipse.swt.widgets.Listener; |
| 33 |
import org.eclipse.swt.widgets.Menu; |
40 |
import org.eclipse.swt.widgets.Menu; |
|
|
41 |
import org.eclipse.swt.widgets.ToolBar; |
| 42 |
import org.eclipse.swt.widgets.ToolItem; |
| 34 |
import org.eclipse.ui.IPropertyListener; |
43 |
import org.eclipse.ui.IPropertyListener; |
| 35 |
import org.eclipse.ui.PlatformUI; |
44 |
import org.eclipse.ui.PlatformUI; |
|
|
45 |
import org.eclipse.ui.internal.IWorkbenchGraphicConstants; |
| 36 |
import org.eclipse.ui.internal.IWorkbenchThemeConstants; |
46 |
import org.eclipse.ui.internal.IWorkbenchThemeConstants; |
|
|
47 |
import org.eclipse.ui.internal.WorkbenchImages; |
| 48 |
import org.eclipse.ui.internal.WorkbenchMessages; |
| 37 |
import org.eclipse.ui.presentations.IPresentablePart; |
49 |
import org.eclipse.ui.presentations.IPresentablePart; |
| 38 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
50 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
| 39 |
import org.eclipse.ui.presentations.PresentationUtil; |
51 |
import org.eclipse.ui.presentations.PresentationUtil; |
|
Lines 52-57
Link Here
|
| 52 |
private boolean activeState = false; |
64 |
private boolean activeState = false; |
| 53 |
private int tabPosition; |
65 |
private int tabPosition; |
| 54 |
private MenuManager systemMenuManager = new MenuManager(); |
66 |
private MenuManager systemMenuManager = new MenuManager(); |
|
|
67 |
private TabFolderLayout layout; |
| 68 |
|
| 69 |
//private ToolBar viewToolBar; |
| 70 |
//private ToolBarManager viewToolBarMgr; |
| 71 |
|
| 72 |
// Controls which will be inserted into the title bar if there is room, or above the client pane |
| 73 |
// if not |
| 74 |
private List topControls = new ArrayList(); |
| 75 |
|
| 76 |
// Stand-in for the top controls |
| 77 |
//private Composite toolbarProxy; |
| 55 |
|
78 |
|
| 56 |
private int mousedownState = -1; |
79 |
private int mousedownState = -1; |
| 57 |
|
80 |
|
|
Lines 128-133
Link Here
|
| 128 |
} |
151 |
} |
| 129 |
}; |
152 |
}; |
| 130 |
|
153 |
|
|
|
154 |
public int getTopTrimStart() { |
| 155 |
return layout.getTrimStart(); |
| 156 |
} |
| 157 |
|
| 131 |
private Listener resizeListener = new Listener() { |
158 |
private Listener resizeListener = new Listener() { |
| 132 |
public void handleEvent(Event e) { |
159 |
public void handleEvent(Event e) { |
| 133 |
setControlSize(); |
160 |
setControlSize(); |
|
Lines 166-175
Link Here
|
| 166 |
} |
193 |
} |
| 167 |
} |
194 |
} |
| 168 |
}; |
195 |
}; |
|
|
196 |
private ToolBar viewToolBar; |
| 169 |
|
197 |
|
| 170 |
public BasicStackPresentation(CTabFolder control, IStackPresentationSite stackSite) { |
198 |
public BasicStackPresentation(CTabFolder control, IStackPresentationSite stackSite) { |
| 171 |
super(stackSite); |
199 |
super(stackSite); |
| 172 |
tabFolder = control; |
200 |
tabFolder = control; |
|
|
201 |
layout = new TabFolderLayout(tabFolder); |
| 173 |
|
202 |
|
| 174 |
// listener to switch between visible tabItems |
203 |
// listener to switch between visible tabItems |
| 175 |
tabFolder.addListener(SWT.Selection, selectionListener); |
204 |
tabFolder.addListener(SWT.Selection, selectionListener); |
|
Lines 204-210
Link Here
|
| 204 |
} |
233 |
} |
| 205 |
} |
234 |
} |
| 206 |
}); |
235 |
}); |
| 207 |
|
236 |
|
|
|
237 |
tabFolder.setTabHeight(24); |
| 238 |
|
| 239 |
viewToolBar = new ToolBar(control.getParent(), SWT.HORIZONTAL | SWT.FLAT | SWT.WRAP); |
| 240 |
|
| 241 |
ToolItem pullDownButton = new ToolItem(viewToolBar, SWT.PUSH); |
| 242 |
// Image img = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU); |
| 243 |
Image hoverImage = |
| 244 |
WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU_HOVER); |
| 245 |
pullDownButton.setDisabledImage(hoverImage); // TODO: comment this out? |
| 246 |
// PR#1GE56QT - Avoid creation of unnecessary image. |
| 247 |
pullDownButton.setImage(hoverImage); |
| 248 |
// pullDownButton.setHotImage(hoverImage); |
| 249 |
pullDownButton.setToolTipText(WorkbenchMessages.getString("Menu")); //$NON-NLS-1$ |
| 250 |
pullDownButton.addSelectionListener(new SelectionAdapter() { |
| 251 |
public void widgetSelected(SelectionEvent e) { |
| 252 |
//showViewMenu(); |
| 253 |
} |
| 254 |
}); |
| 255 |
|
| 256 |
viewToolBar.setVisible(true); |
| 257 |
//viewToolBar.moveAbove(null); |
| 258 |
|
| 259 |
// Insert a bogus composite into the top-right of the tab folder. We do this to keep |
| 260 |
// track of where to draw the toolbars. |
| 261 |
//toolbarProxy = new Composite(tabFolder, SWT.NONE); |
| 262 |
|
| 263 |
//tabFolder.setTopRight(toolbarProxy); |
| 208 |
} |
264 |
} |
| 209 |
|
265 |
|
| 210 |
/** |
266 |
/** |
|
Lines 306-313
Link Here
|
| 306 |
} |
362 |
} |
| 307 |
|
363 |
|
| 308 |
public void drawGradient(Color fgColor, Color [] bgColors, int [] percentages, boolean vertical) { |
364 |
public void drawGradient(Color fgColor, Color [] bgColors, int [] percentages, boolean vertical) { |
|
|
365 |
Display display = tabFolder.getDisplay(); |
| 366 |
Color c = display.getSystemColor(SWT.COLOR_BLUE); |
| 367 |
|
| 368 |
//fgColor = c; |
| 369 |
// tabFolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), |
| 370 |
// display.getSystemColor(SWT.COLOR_BLUE), |
| 371 |
// display.getSystemColor(SWT.COLOR_WHITE), |
| 372 |
// display.getSystemColor(SWT.COLOR_WHITE)}, |
| 373 |
// new int[] {25, 50, 100}); |
| 374 |
|
| 375 |
//tabFolder.setBackground(display.getSystemColor(SWT.COLOR_DARK_BLUE)); |
| 376 |
|
| 309 |
tabFolder.setSelectionForeground(fgColor); |
377 |
tabFolder.setSelectionForeground(fgColor); |
| 310 |
tabFolder.setSelectionBackground(bgColors, percentages, vertical); |
378 |
tabFolder.setSelectionBackground(bgColors, percentages, vertical); |
| 311 |
} |
379 |
} |
| 312 |
|
380 |
|
| 313 |
public boolean isActive() { |
381 |
public boolean isActive() { |
|
Lines 317-347
Link Here
|
| 317 |
/** |
385 |
/** |
| 318 |
* Set the size of a page in the folder. |
386 |
* Set the size of a page in the folder. |
| 319 |
*/ |
387 |
*/ |
| 320 |
private void setControlSize() { |
388 |
protected void setControlSize() { |
| 321 |
if (current == null || tabFolder == null) |
389 |
if (current == null || tabFolder == null) |
| 322 |
return; |
390 |
return; |
| 323 |
// Rectangle bounds; |
391 |
|
| 324 |
// @issue as above, the mere presence of a theme should not change the behaviour |
392 |
layout.layout(); |
| 325 |
// if ((mapTabToPart.size() > 1) |
393 |
|
| 326 |
// || ((tabThemeDescriptor != null) && (mapTabToPart.size() >= 1))) |
394 |
current.setBounds(layout.getClientBounds()); |
| 327 |
// bounds = calculatePageBounds(tabFolder); |
395 |
} |
| 328 |
// else |
396 |
|
| 329 |
// bounds = tabFolder.getBounds(); |
397 |
protected boolean isTrimOnTop() { |
| 330 |
current.setBounds(calculatePageBounds(tabFolder)); |
398 |
return layout.isTrimOnTop(); |
| 331 |
//current.moveAbove(tabFolder); |
399 |
} |
| 332 |
} |
400 |
|
| 333 |
|
401 |
// protected Control[] getTopRight() { |
| 334 |
public static Rectangle calculatePageBounds(CTabFolder folder) { |
402 |
// return layout.getTopRight(); |
| 335 |
if (folder == null) |
403 |
// } |
| 336 |
return new Rectangle(0, 0, 0, 0); |
|
|
| 337 |
Rectangle bounds = folder.getBounds(); |
| 338 |
Rectangle offset = folder.getClientArea(); |
| 339 |
bounds.x += offset.x; |
| 340 |
bounds.y += offset.y; |
| 341 |
bounds.width = offset.width; |
| 342 |
bounds.height = offset.height; |
| 343 |
return bounds; |
| 344 |
} |
| 345 |
|
404 |
|
| 346 |
/* (non-Javadoc) |
405 |
/* (non-Javadoc) |
| 347 |
* @see org.eclipse.ui.internal.skins.Presentation#dispose() |
406 |
* @see org.eclipse.ui.internal.skins.Presentation#dispose() |
|
Lines 355-360
Link Here
|
| 355 |
|
414 |
|
| 356 |
tabFolder.dispose(); |
415 |
tabFolder.dispose(); |
| 357 |
tabFolder = null; |
416 |
tabFolder = null; |
|
|
417 |
|
| 418 |
viewToolBar.dispose(); |
| 358 |
} |
419 |
} |
| 359 |
|
420 |
|
| 360 |
/* (non-Javadoc) |
421 |
/* (non-Javadoc) |
|
Lines 444-457
Link Here
|
| 444 |
setControlSize(); |
505 |
setControlSize(); |
| 445 |
current.setVisible(true); |
506 |
current.setVisible(true); |
| 446 |
} |
507 |
} |
|
|
508 |
|
| 509 |
// Set up the top-right controls |
| 510 |
List topRight = new ArrayList(2); |
| 511 |
|
| 512 |
Control toolbar = getCurrentToolbar(); |
| 513 |
|
| 514 |
if (toolbar != null) { |
| 515 |
topRight.add(toolbar); |
| 516 |
} |
| 517 |
|
| 518 |
viewToolBar.moveAbove(null); |
| 519 |
viewToolBar.setBackground(toolbar.getBackground()); |
| 520 |
topRight.add(viewToolBar); |
| 521 |
|
| 522 |
Control[] controls = (Control[])topRight.toArray(new Control[topRight.size()]); |
| 523 |
|
| 524 |
layout.setTopRight(controls); |
| 447 |
} |
525 |
} |
| 448 |
|
526 |
|
|
|
527 |
|
| 528 |
public IPresentablePart getCurrentPart() { |
| 529 |
return current; |
| 530 |
} |
| 531 |
|
| 532 |
// protected void setTopRight(List topRight) { |
| 533 |
// layout.setTopRight(topRight); |
| 534 |
// setControlSize(); |
| 535 |
// } |
| 536 |
|
| 449 |
/* (non-Javadoc) |
537 |
/* (non-Javadoc) |
| 450 |
* @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle) |
538 |
* @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle) |
| 451 |
*/ |
539 |
*/ |
| 452 |
public void setBounds(Rectangle bounds) { |
540 |
public void setBounds(Rectangle bounds) { |
| 453 |
tabFolder.setBounds(bounds); |
541 |
tabFolder.setBounds(bounds); |
| 454 |
setControlSize(); |
542 |
setControlSize(); |
|
|
543 |
viewToolBar.moveAbove(getControl()); |
| 455 |
} |
544 |
} |
| 456 |
|
545 |
|
| 457 |
/* (non-Javadoc) |
546 |
/* (non-Javadoc) |
|
Lines 508-514
Link Here
|
| 508 |
* @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point) |
597 |
* @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point) |
| 509 |
*/ |
598 |
*/ |
| 510 |
public StackDropResult dragOver(Control currentControl, Point location) { |
599 |
public StackDropResult dragOver(Control currentControl, Point location) { |
| 511 |
|
|
|
| 512 |
// Determine which tab we're currently dragging over |
600 |
// Determine which tab we're currently dragging over |
| 513 |
Point localPos = tabFolder.toControl(location); |
601 |
Point localPos = tabFolder.toControl(location); |
| 514 |
final CTabItem tabUnderPointer = tabFolder.getItem(localPos); |
602 |
final CTabItem tabUnderPointer = tabFolder.getItem(localPos); |
|
Lines 522-525
Link Here
|
| 522 |
return new StackDropResult(Geometry.toDisplay(tabFolder, tabUnderPointer.getBounds()), |
610 |
return new StackDropResult(Geometry.toDisplay(tabFolder, tabUnderPointer.getBounds()), |
| 523 |
tabFolder.indexOf(tabUnderPointer)); |
611 |
tabFolder.indexOf(tabUnderPointer)); |
| 524 |
} |
612 |
} |
|
|
613 |
|
| 614 |
public int getGradientPercentage() { |
| 615 |
Rectangle clientBounds = getTabFolder().getBounds(); |
| 616 |
|
| 617 |
int percentage = clientBounds.width == 0 ? 100 : Math.min(100, |
| 618 |
100 * getTopTrimStart() / clientBounds.width); |
| 619 |
|
| 620 |
if (percentage < 0) { |
| 621 |
percentage = 0; |
| 622 |
} |
| 623 |
|
| 624 |
return percentage; |
| 625 |
} |
| 626 |
|
| 627 |
protected Control getCurrentToolbar() { |
| 628 |
IPresentablePart part = getCurrentPart(); |
| 629 |
if (part == null) { |
| 630 |
return null; |
| 631 |
} |
| 632 |
|
| 633 |
return part.getToolBar(); |
| 634 |
} |
| 635 |
|
| 525 |
} |
636 |
} |