|
Lines 23-40
Link Here
|
| 23 |
import org.eclipse.e4.core.contexts.RunAndTrack; |
23 |
import org.eclipse.e4.core.contexts.RunAndTrack; |
| 24 |
import org.eclipse.e4.core.services.events.IEventBroker; |
24 |
import org.eclipse.e4.core.services.events.IEventBroker; |
| 25 |
import org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer; |
25 |
import org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer; |
|
|
26 |
import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer; |
| 26 |
import org.eclipse.e4.ui.model.application.MApplication; |
27 |
import org.eclipse.e4.ui.model.application.MApplication; |
| 27 |
import org.eclipse.e4.ui.model.application.ui.MElementContainer; |
28 |
import org.eclipse.e4.ui.model.application.ui.MElementContainer; |
| 28 |
import org.eclipse.e4.ui.model.application.ui.MUIElement; |
29 |
import org.eclipse.e4.ui.model.application.ui.MUIElement; |
| 29 |
import org.eclipse.e4.ui.model.application.ui.SideValue; |
30 |
import org.eclipse.e4.ui.model.application.ui.SideValue; |
|
|
31 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
| 30 |
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; |
32 |
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; |
| 31 |
import org.eclipse.e4.ui.model.application.ui.menu.MDirectToolItem; |
33 |
import org.eclipse.e4.ui.model.application.ui.menu.MDirectToolItem; |
| 32 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem; |
34 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem; |
|
|
35 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenu; |
| 33 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; |
36 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; |
| 34 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarContribution; |
37 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarContribution; |
| 35 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement; |
38 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement; |
| 36 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarSeparator; |
39 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarSeparator; |
| 37 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; |
40 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; |
|
|
41 |
import org.eclipse.e4.ui.workbench.IPresentationEngine; |
| 38 |
import org.eclipse.e4.ui.workbench.UIEvents; |
42 |
import org.eclipse.e4.ui.workbench.UIEvents; |
| 39 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
43 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
| 40 |
import org.eclipse.e4.ui.workbench.modeling.ExpressionContext; |
44 |
import org.eclipse.e4.ui.workbench.modeling.ExpressionContext; |
|
Lines 44-58
Link Here
|
| 44 |
import org.eclipse.jface.action.ContributionItem; |
48 |
import org.eclipse.jface.action.ContributionItem; |
| 45 |
import org.eclipse.jface.action.GroupMarker; |
49 |
import org.eclipse.jface.action.GroupMarker; |
| 46 |
import org.eclipse.jface.action.IContributionItem; |
50 |
import org.eclipse.jface.action.IContributionItem; |
| 47 |
import org.eclipse.jface.action.IContributionManager; |
|
|
| 48 |
import org.eclipse.jface.action.Separator; |
51 |
import org.eclipse.jface.action.Separator; |
| 49 |
import org.eclipse.jface.action.ToolBarManager; |
52 |
import org.eclipse.jface.action.ToolBarManager; |
| 50 |
import org.eclipse.jface.layout.RowLayoutFactory; |
|
|
| 51 |
import org.eclipse.swt.SWT; |
53 |
import org.eclipse.swt.SWT; |
| 52 |
import org.eclipse.swt.layout.RowLayout; |
54 |
import org.eclipse.swt.events.DisposeEvent; |
|
|
55 |
import org.eclipse.swt.events.DisposeListener; |
| 56 |
import org.eclipse.swt.events.SelectionEvent; |
| 57 |
import org.eclipse.swt.events.SelectionListener; |
| 58 |
import org.eclipse.swt.graphics.Color; |
| 59 |
import org.eclipse.swt.graphics.GC; |
| 60 |
import org.eclipse.swt.graphics.Image; |
| 61 |
import org.eclipse.swt.graphics.ImageData; |
| 62 |
import org.eclipse.swt.graphics.Point; |
| 63 |
import org.eclipse.swt.graphics.Rectangle; |
| 53 |
import org.eclipse.swt.widgets.Composite; |
64 |
import org.eclipse.swt.widgets.Composite; |
|
|
65 |
import org.eclipse.swt.widgets.Control; |
| 66 |
import org.eclipse.swt.widgets.Display; |
| 67 |
import org.eclipse.swt.widgets.Menu; |
| 54 |
import org.eclipse.swt.widgets.ToolBar; |
68 |
import org.eclipse.swt.widgets.ToolBar; |
| 55 |
import org.eclipse.swt.widgets.ToolItem; |
69 |
import org.eclipse.swt.widgets.ToolItem; |
|
|
70 |
import org.eclipse.swt.widgets.Widget; |
| 56 |
import org.osgi.service.event.Event; |
71 |
import org.osgi.service.event.Event; |
| 57 |
import org.osgi.service.event.EventHandler; |
72 |
import org.osgi.service.event.EventHandler; |
| 58 |
|
73 |
|
|
Lines 66-75
Link Here
|
| 66 |
|
81 |
|
| 67 |
private Map<MToolBarElement, IContributionItem> modelToContribution = new HashMap<MToolBarElement, IContributionItem>(); |
82 |
private Map<MToolBarElement, IContributionItem> modelToContribution = new HashMap<MToolBarElement, IContributionItem>(); |
| 68 |
|
83 |
|
|
|
84 |
private ArrayList<ContributionRecord> contributionRecords = new ArrayList<ContributionRecord>(); |
| 85 |
|
| 69 |
// @Inject |
86 |
// @Inject |
| 70 |
// private Logger logger; |
87 |
// private Logger logger; |
| 71 |
|
88 |
|
| 72 |
@Inject |
89 |
@Inject |
|
|
90 |
IPresentationEngine renderer; |
| 91 |
@Inject |
| 73 |
private MApplication application; |
92 |
private MApplication application; |
| 74 |
@Inject |
93 |
@Inject |
| 75 |
private EModelService modelService; |
94 |
private EModelService modelService; |
|
Lines 121-126
Link Here
|
| 121 |
if (itemModel.isToBeRendered()) { |
140 |
if (itemModel.isToBeRendered()) { |
| 122 |
if (parent != null) { |
141 |
if (parent != null) { |
| 123 |
modelProcessSwitch(parent, itemModel); |
142 |
modelProcessSwitch(parent, itemModel); |
|
|
143 |
parent.update(true); |
| 144 |
ToolBar tb = parent.getControl(); |
| 145 |
if (tb != null && !tb.isDisposed()) { |
| 146 |
tb.getShell().layout(new Control[] { tb }, |
| 147 |
SWT.DEFER); |
| 148 |
} |
| 124 |
} |
149 |
} |
| 125 |
} else { |
150 |
} else { |
| 126 |
IContributionItem ici = modelToContribution |
151 |
IContributionItem ici = modelToContribution |
|
Lines 138-147
Link Here
|
| 138 |
return; |
163 |
return; |
| 139 |
} |
164 |
} |
| 140 |
ici.setVisible(itemModel.isVisible()); |
165 |
ici.setVisible(itemModel.isVisible()); |
| 141 |
IContributionManager parent = ((ContributionItem) ici) |
166 |
ToolBarManager parent = (ToolBarManager) ((ContributionItem) ici) |
| 142 |
.getParent(); |
167 |
.getParent(); |
| 143 |
if (parent != null) { |
168 |
if (parent != null) { |
| 144 |
parent.markDirty(); |
169 |
parent.markDirty(); |
|
|
170 |
ToolBar tb = parent.getControl(); |
| 171 |
if (tb != null && !tb.isDisposed()) { |
| 172 |
tb.getShell().layout(new Control[] { tb }, SWT.DEFER); |
| 173 |
} |
| 145 |
} |
174 |
} |
| 146 |
} |
175 |
} |
| 147 |
} |
176 |
} |
|
Lines 176-181
Link Here
|
| 176 |
} |
205 |
} |
| 177 |
} |
206 |
} |
| 178 |
}; |
207 |
}; |
|
|
208 |
private Image viewMenuImage; |
| 179 |
|
209 |
|
| 180 |
@PostConstruct |
210 |
@PostConstruct |
| 181 |
public void init() { |
211 |
public void init() { |
|
Lines 212-222
Link Here
|
| 212 |
return null; |
242 |
return null; |
| 213 |
|
243 |
|
| 214 |
// HACK!! This should be done using a separate renderer |
244 |
// HACK!! This should be done using a separate renderer |
| 215 |
Composite intermediate = new Composite((Composite) parent, SWT.NONE); |
245 |
// Composite intermediate = new Composite((Composite) parent, SWT.NONE); |
| 216 |
createToolbar(element, intermediate); |
246 |
ToolBar bar = createToolbar(element, (Composite) parent); |
| 217 |
processContribution((MToolBar) element); |
247 |
processContribution((MToolBar) element); |
| 218 |
|
248 |
|
| 219 |
return intermediate; |
249 |
return bar; |
| 220 |
} |
250 |
} |
| 221 |
|
251 |
|
| 222 |
/** |
252 |
/** |
|
Lines 295-300
Link Here
|
| 295 |
} |
325 |
} |
| 296 |
manager.markDirty(); |
326 |
manager.markDirty(); |
| 297 |
} |
327 |
} |
|
|
328 |
|
| 329 |
public void dispose() { |
| 330 |
for (MToolBarElement copy : generatedElements) { |
| 331 |
toolbarModel.getChildren().remove(copy); |
| 332 |
} |
| 333 |
} |
| 298 |
} |
334 |
} |
| 299 |
|
335 |
|
| 300 |
/** |
336 |
/** |
|
Lines 313-318
Link Here
|
| 313 |
} |
349 |
} |
| 314 |
final ContributionRecord record = new ContributionRecord(toolbarModel, |
350 |
final ContributionRecord record = new ContributionRecord(toolbarModel, |
| 315 |
contribution, manager); |
351 |
contribution, manager); |
|
|
352 |
contributionRecords.add(record); |
| 316 |
record.generate(); |
353 |
record.generate(); |
| 317 |
for (MToolBarElement copy : record.generatedElements) { |
354 |
for (MToolBarElement copy : record.generatedElements) { |
| 318 |
if (copy instanceof MToolBarSeparator |
355 |
if (copy instanceof MToolBarSeparator |
|
Lines 332-339
Link Here
|
| 332 |
parentContext.runAndTrack(new RunAndTrack() { |
369 |
parentContext.runAndTrack(new RunAndTrack() { |
| 333 |
@Override |
370 |
@Override |
| 334 |
public boolean changed(IEclipseContext context) { |
371 |
public boolean changed(IEclipseContext context) { |
| 335 |
record.updateVisibility(parentContext); |
372 |
record.updateVisibility(parentContext.getActiveLeaf()); |
| 336 |
manager.update(true); |
373 |
manager.update(false); |
| 337 |
return true; |
374 |
return true; |
| 338 |
} |
375 |
} |
| 339 |
}); |
376 |
}); |
|
Lines 369-395
Link Here
|
| 369 |
return id.equals("additions") ? menuModel.getChildren().size() : -1; //$NON-NLS-1$ |
406 |
return id.equals("additions") ? menuModel.getChildren().size() : -1; //$NON-NLS-1$ |
| 370 |
} |
407 |
} |
| 371 |
|
408 |
|
| 372 |
ToolBar createToolbar(final MUIElement element, Composite intermediate) { |
409 |
private ToolBar createToolbar(final MUIElement element, |
|
|
410 |
Composite intermediate) { |
| 373 |
int orientation = getOrientation(element); |
411 |
int orientation = getOrientation(element); |
| 374 |
RowLayout layout = RowLayoutFactory.fillDefaults().wrap(false) |
412 |
|
| 375 |
.spacing(0).type(orientation).create(); |
413 |
ToolBarManager manager = getManager((MToolBar) element); |
| 376 |
layout.marginLeft = 3; |
414 |
if (manager == null) { |
| 377 |
layout.center = true; |
415 |
manager = new ToolBarManager(orientation | SWT.WRAP | SWT.FLAT |
| 378 |
intermediate.setLayout(layout); |
416 |
| SWT.RIGHT); |
| 379 |
// new Label(intermediate, (orientation == SWT.HORIZONTAL ? SWT.VERTICAL |
417 |
linkModelToManager((MToolBar) element, manager); |
| 380 |
// : SWT.HORIZONTAL) | SWT.SEPARATOR); |
418 |
} |
| 381 |
|
|
|
| 382 |
ToolBar separatorToolBar = new ToolBar(intermediate, orientation |
| 383 |
| SWT.WRAP | SWT.FLAT | SWT.RIGHT); |
| 384 |
new ToolItem(separatorToolBar, SWT.SEPARATOR); |
| 385 |
ToolBarManager manager = new ToolBarManager(orientation | SWT.WRAP |
| 386 |
| SWT.FLAT | SWT.RIGHT); |
| 387 |
modelToManager.put((MToolBar) element, manager); |
| 388 |
ToolBar bar = manager.createControl(intermediate); |
419 |
ToolBar bar = manager.createControl(intermediate); |
| 389 |
bar.setData(manager); |
420 |
bar.setData(manager); |
|
|
421 |
bar.getShell().layout(new Control[] { bar }, SWT.DEFER); |
| 422 |
bar.addDisposeListener(new DisposeListener() { |
| 423 |
public void widgetDisposed(DisposeEvent e) { |
| 424 |
cleanUp((MToolBar) element); |
| 425 |
} |
| 426 |
}); |
| 390 |
return bar; |
427 |
return bar; |
| 391 |
} |
428 |
} |
| 392 |
|
429 |
|
|
|
430 |
/** |
| 431 |
* @param element |
| 432 |
*/ |
| 433 |
protected void cleanUp(MToolBar toolbarModel) { |
| 434 |
for (ContributionRecord record : contributionRecords |
| 435 |
.toArray(new ContributionRecord[contributionRecords.size()])) { |
| 436 |
if (record.toolbarModel == toolbarModel) { |
| 437 |
record.dispose(); |
| 438 |
contributionRecords.remove(record); |
| 439 |
for (MToolBarElement copy : record.generatedElements) { |
| 440 |
IContributionItem ici = modelToContribution.remove(copy); |
| 441 |
if (ici != null) { |
| 442 |
record.manager.remove(ici); |
| 443 |
} |
| 444 |
} |
| 445 |
record.generatedElements.clear(); |
| 446 |
} |
| 447 |
} |
| 448 |
} |
| 449 |
|
| 393 |
int getOrientation(final MUIElement element) { |
450 |
int getOrientation(final MUIElement element) { |
| 394 |
MUIElement theParent = element.getParent(); |
451 |
MUIElement theParent = element.getParent(); |
| 395 |
if (theParent instanceof MTrimBar) { |
452 |
if (theParent instanceof MTrimBar) { |
|
Lines 417-423
Link Here
|
| 417 |
if (container == null) |
474 |
if (container == null) |
| 418 |
return; |
475 |
return; |
| 419 |
|
476 |
|
| 420 |
ToolBarManager parentManager = modelToManager.get(container); |
477 |
Object obj = container; |
|
|
478 |
ToolBarManager parentManager = getManager((MToolBar) obj); |
| 421 |
if (parentManager == null) { |
479 |
if (parentManager == null) { |
| 422 |
return; |
480 |
return; |
| 423 |
} |
481 |
} |
|
Lines 431-436
Link Here
|
| 431 |
} |
489 |
} |
| 432 |
} |
490 |
} |
| 433 |
parentManager.update(false); |
491 |
parentManager.update(false); |
|
|
492 |
|
| 493 |
ToolBar tb = (ToolBar) container.getWidget(); |
| 494 |
if (((EObject) container).eContainer() instanceof MPart) { |
| 495 |
MPart part = (MPart) ((EObject) container).eContainer(); |
| 496 |
MMenu viewMenu = getViewMenu(part); |
| 497 |
|
| 498 |
// View menu (if any) |
| 499 |
if (viewMenu != null) { |
| 500 |
addMenuButton(part, tb, viewMenu); |
| 501 |
} |
| 502 |
} |
| 503 |
tb.getShell().layout(new Control[] { tb }, SWT.DEFER); |
| 504 |
} |
| 505 |
|
| 506 |
/** |
| 507 |
* @param tb |
| 508 |
*/ |
| 509 |
private void addMenuButton(MPart part, ToolBar tb, MMenu menu) { |
| 510 |
ToolItem ti = new ToolItem(tb, SWT.PUSH); |
| 511 |
ti.setImage(getViewMenuImage()); |
| 512 |
ti.setHotImage(null); |
| 513 |
ti.setToolTipText("View Menu"); //$NON-NLS-1$ |
| 514 |
ti.setData("theMenu", menu); //$NON-NLS-1$ |
| 515 |
ti.setData("thePart", part); //$NON-NLS-1$ |
| 516 |
|
| 517 |
ti.addSelectionListener(new SelectionListener() { |
| 518 |
public void widgetSelected(SelectionEvent e) { |
| 519 |
showMenu((ToolItem) e.widget); |
| 520 |
} |
| 521 |
|
| 522 |
public void widgetDefaultSelected(SelectionEvent e) { |
| 523 |
showMenu((ToolItem) e.widget); |
| 524 |
} |
| 525 |
}); |
| 526 |
} |
| 527 |
|
| 528 |
/** |
| 529 |
* @param item |
| 530 |
*/ |
| 531 |
protected void showMenu(ToolItem item) { |
| 532 |
// Create the UI for the menu |
| 533 |
final MMenu menuModel = (MMenu) item.getData("theMenu"); //$NON-NLS-1$ |
| 534 |
MPart part = (MPart) item.getData("thePart"); //$NON-NLS-1$ |
| 535 |
Control ctrl = (Control) part.getWidget(); |
| 536 |
Menu menu = (Menu) renderer.createGui(menuModel, ctrl.getShell(), |
| 537 |
part.getContext()); |
| 538 |
|
| 539 |
// ...and Show it... |
| 540 |
Rectangle ib = item.getBounds(); |
| 541 |
Point displayAt = item.getParent().toDisplay(ib.x, ib.y + ib.height); |
| 542 |
menu.setLocation(displayAt); |
| 543 |
menu.setVisible(true); |
| 544 |
|
| 545 |
Display display = Display.getCurrent(); |
| 546 |
while (!menu.isDisposed() && menu.isVisible()) { |
| 547 |
if (!display.readAndDispatch()) |
| 548 |
display.sleep(); |
| 549 |
} |
| 550 |
menu.dispose(); |
| 551 |
} |
| 552 |
|
| 553 |
private Image getViewMenuImage() { |
| 554 |
if (viewMenuImage == null) { |
| 555 |
Display d = Display.getCurrent(); |
| 556 |
|
| 557 |
Image viewMenu = new Image(d, 16, 16); |
| 558 |
Image viewMenuMask = new Image(d, 16, 16); |
| 559 |
|
| 560 |
Display display = Display.getCurrent(); |
| 561 |
GC gc = new GC(viewMenu); |
| 562 |
GC maskgc = new GC(viewMenuMask); |
| 563 |
gc.setForeground(display |
| 564 |
.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); |
| 565 |
gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND)); |
| 566 |
|
| 567 |
int[] shapeArray = new int[] { 6, 1, 15, 1, 11, 5, 10, 5 }; |
| 568 |
gc.fillPolygon(shapeArray); |
| 569 |
gc.drawPolygon(shapeArray); |
| 570 |
|
| 571 |
Color black = display.getSystemColor(SWT.COLOR_BLACK); |
| 572 |
Color white = display.getSystemColor(SWT.COLOR_WHITE); |
| 573 |
|
| 574 |
maskgc.setBackground(black); |
| 575 |
maskgc.fillRectangle(0, 0, 16, 16); |
| 576 |
|
| 577 |
maskgc.setBackground(white); |
| 578 |
maskgc.setForeground(white); |
| 579 |
maskgc.fillPolygon(shapeArray); |
| 580 |
maskgc.drawPolygon(shapeArray); |
| 581 |
gc.dispose(); |
| 582 |
maskgc.dispose(); |
| 583 |
|
| 584 |
ImageData data = viewMenu.getImageData(); |
| 585 |
data.transparentPixel = data.getPixel(0, 0); |
| 586 |
|
| 587 |
viewMenuImage = new Image(d, viewMenu.getImageData(), |
| 588 |
viewMenuMask.getImageData()); |
| 589 |
viewMenu.dispose(); |
| 590 |
viewMenuMask.dispose(); |
| 591 |
} |
| 592 |
return viewMenuImage; |
| 593 |
} |
| 594 |
|
| 595 |
private MMenu getViewMenu(MPart part) { |
| 596 |
if (part.getMenus() == null) { |
| 597 |
return null; |
| 598 |
} |
| 599 |
for (MMenu menu : part.getMenus()) { |
| 600 |
if (menu.getTags().contains(StackRenderer.TAG_VIEW_MENU)) { |
| 601 |
return menu; |
| 602 |
} |
| 603 |
} |
| 604 |
return null; |
| 605 |
} |
| 606 |
|
| 607 |
boolean hasOnlySeparators(ToolBar toolbar) { |
| 608 |
ToolItem[] children = toolbar.getItems(); |
| 609 |
for (ToolItem toolItem : children) { |
| 610 |
if ((toolItem.getStyle() & SWT.SEPARATOR) == 0) { |
| 611 |
return false; |
| 612 |
} else if (toolItem.getControl() != null |
| 613 |
&& toolItem.getControl().getData(OWNING_ME) instanceof MToolControl) { |
| 614 |
return false; |
| 615 |
} |
| 616 |
} |
| 617 |
return true; |
| 618 |
} |
| 619 |
|
| 620 |
ToolBar findToolbar(Composite intermediate) { |
| 621 |
if (!intermediate.isDisposed()) { |
| 622 |
Control[] children = intermediate.getChildren(); |
| 623 |
int length = children.length; |
| 624 |
if (length > 0 && children[length - 1] instanceof ToolBar) { |
| 625 |
return (ToolBar) children[length - 1]; |
| 626 |
} |
| 627 |
} |
| 628 |
return null; |
| 629 |
} |
| 630 |
|
| 631 |
@Override |
| 632 |
public void postProcess(MUIElement element) { |
| 633 |
super.postProcess(element); |
| 634 |
// disposeToolbarIfNecessary(element); |
| 635 |
if (element.getWidget() instanceof ToolBar) { |
| 636 |
ToolBar toolbar = (ToolBar) element.getWidget(); |
| 637 |
if (toolbar != null && !toolbar.isDisposed()) { |
| 638 |
toolbar.getShell().layout(new Control[] { toolbar }, SWT.DEFER); |
| 639 |
} |
| 640 |
toolbar.setVisible(true); |
| 641 |
} |
| 642 |
} |
| 643 |
|
| 644 |
public Object getUIContainer(MUIElement childElement) { |
| 645 |
if (childElement.getWidget() instanceof ToolBar) { |
| 646 |
return childElement.getWidget(); |
| 647 |
} |
| 648 |
|
| 649 |
Object obj = super.getUIContainer(childElement); |
| 650 |
if (obj instanceof ToolBar) { |
| 651 |
return obj; |
| 652 |
} |
| 653 |
|
| 654 |
if (obj instanceof Composite) { |
| 655 |
Composite intermediate = (Composite) obj; |
| 656 |
if (intermediate == null || intermediate.isDisposed()) { |
| 657 |
return null; |
| 658 |
} |
| 659 |
ToolBar toolbar = findToolbar(intermediate); |
| 660 |
if (toolbar == null) { |
| 661 |
toolbar = createToolbar(childElement.getParent(), intermediate); |
| 662 |
} |
| 663 |
return toolbar; |
| 664 |
} |
| 665 |
return null; |
| 666 |
} |
| 667 |
|
| 668 |
@Override |
| 669 |
public void disposeWidget(MUIElement element) { |
| 670 |
ToolBar tb = (ToolBar) element.getWidget(); |
| 671 |
tb.setVisible(false); |
| 672 |
unbindWidget(element); |
| 673 |
tb.setData(AbstractPartRenderer.OWNING_ME, element); |
| 674 |
} |
| 675 |
|
| 676 |
@Override |
| 677 |
public void hideChild(MElementContainer<MUIElement> parentElement, |
| 678 |
MUIElement child) { |
| 679 |
super.hideChild(parentElement, child); |
| 680 |
|
| 681 |
// Since there's no place to 'store' a child that's not in a menu |
| 682 |
// we'll blow it away and re-create on an add |
| 683 |
Widget widget = (Widget) child.getWidget(); |
| 684 |
if (widget != null && !widget.isDisposed()) { |
| 685 |
widget.dispose(); |
| 686 |
} |
| 687 |
ToolBar toolbar = (ToolBar) getUIContainer(child); |
| 688 |
if (toolbar != null && !toolbar.isDisposed()) { |
| 689 |
toolbar.getShell().layout(new Control[] { toolbar }, SWT.DEFER); |
| 690 |
} |
| 691 |
// disposeToolbarIfNecessary(parentElement); |
| 692 |
} |
| 693 |
|
| 694 |
@Override |
| 695 |
public void childRendered(MElementContainer<MUIElement> parentElement, |
| 696 |
MUIElement element) { |
| 697 |
super.childRendered(parentElement, element); |
| 698 |
ToolBar toolbar = (ToolBar) getUIContainer(element); |
| 699 |
if (toolbar != null && !toolbar.isDisposed()) { |
| 700 |
toolbar.getShell().layout(new Control[] { toolbar }, SWT.DEFER); |
| 701 |
} |
| 434 |
} |
702 |
} |
| 435 |
|
703 |
|
| 436 |
/** |
704 |
/** |