private static boolean hasVisibleItems(MToolBar toolBar) { for (MToolBarElement e : toolBar.getChildren()) { if (!(e instanceof MToolBarSeparator)) { return true; } } return false; }
protected void cleanUp(MToolBar element) { ArrayList<ArrayList<MToolBarElement>> lists = pendingCleanup .remove(element); if (lists == null) { return; } for (ArrayList<MToolBarElement> list : lists) { for (MToolBarElement child : list) { element.getChildren().remove(child); } } }
MToolBarSeparator findExistingSeparator(String id) { if (id == null) { return null; } for (MToolBarElement item : toolbarModel.getChildren()) { if (item instanceof MToolBarSeparator && id.equals(item.getElementId())) { return (MToolBarSeparator) item; } } return null; }
private void createToolbarEntries(MToolBar toolbar, DisplayItem parent) { if (toolbar == null) { return; } for (MToolBarElement element : toolbar.getChildren()) { createToolbarEntry(parent, element); } }
MToolBarSeparator findExistingSeparator(String id) { if (id == null) { return null; } for (MToolBarElement item : toolbarModel.getChildren()) { if (item instanceof MToolBarSeparator && id.equals(item.getElementId())) { return (MToolBarSeparator) item; } } return null; }
public void dispose() { for (MToolBarElement copy : generatedElements) { toolbarModel.getChildren().remove(copy); } for (MToolBarElement shared : sharedElements) { ArrayList<ToolBarContributionRecord> array = renderer .getList(shared); array.remove(this); if (array.isEmpty()) { toolbarModel.getChildren().remove(shared); } } if (factoryDispose != null) { factoryDispose.run(); factoryDispose = null; } }
public void dispose() { for (MToolBarElement copy : generatedElements) { toolbarModel.getChildren().remove(copy); } for (MToolBarElement shared : sharedElements) { ArrayList<ToolBarContributionRecord> array = renderer .getList(shared); array.remove(this); if (array.isEmpty()) { toolbarModel.getChildren().remove(shared); } } if (factoryDispose != null) { factoryDispose.run(); factoryDispose = null; } }
/** * @param model * @param item */ public void clearModelToContribution(MToolBarElement model, IContributionItem item) { if (model instanceof MToolBar) { for (MToolBarElement element : ((MToolBar) model).getChildren()) { IContributionItem ici = getContribution(element); clearModelToContribution(element, ici); } } modelToContribution.remove(model); contributionToModel.remove(item); if (Policy.DEBUG_RENDERER) { logger.debug( "\nTBMR:clearModelToContribution: modelToContribution size = {0}, contributionToModel size = {1}", //$NON-NLS-1$ modelToContribution.size(), contributionToModel.size()); } }
public static void clearOpaqueToolBarItems(ToolBarManagerRenderer tbmr, MToolBar toolbar) { // remove opaque mappings for (Iterator<MToolBarElement> it = toolbar.getChildren().iterator(); it.hasNext();) { MToolBarElement element = it.next(); IContributionItem contribution = tbmr.getContribution(element); if (contribution != null) { tbmr.clearModelToContribution(element, contribution); } if (OpaqueElementUtil.isOpaqueToolItem(element)) { // clear the reference OpaqueElementUtil.clearOpaqueItem(element); // remove the opaque item it.remove(); } } }
/** * @param model * @param manager */ public void clearModelToManager(MToolBar model, ToolBarManager manager) { for (MToolBarElement element : model.getChildren()) { if (element instanceof MToolBar) { clearModelToManager((MToolBar) element, getManager((MToolBar) element)); } IContributionItem ici = getContribution(element); clearModelToContribution(element, ici); } ToolBarManager removed = modelToManager.remove(model); if (manager == null) { managerToModel.remove(removed); } else { managerToModel.remove(manager); } if (Policy.DEBUG_RENDERER) { logger.debug("\nTBMR:clearModelToManager: modelToManager size = {0}, managerToModel size = {1}", //$NON-NLS-1$ modelToManager.size(), managerToModel.size()); } }
HashMap<MToolBar, ArrayList<ArrayList<MToolBarElement>>> pendingCleanup) { HashSet<String> existingSeparatorNames = new HashSet<String>(); for (MToolBarElement child : toolbarModel.getChildren()) { String elementId = child.getElementId(); if (child instanceof MToolBarSeparator && elementId != null) {
if (child instanceof MToolBar) { MToolBar toolbar = (MToolBar) child; for (MToolBarElement element : toolbar.getChildren()) { if (OpaqueElementUtil.isOpaqueToolItem(element)) { toRemove.add(element); toolbar.getChildren().removeAll(toRemove); toRemove.clear();
public void reconcileManagerToModel(IToolBarManager menuManager, MToolBar toolBar) { List<MToolBarElement> modelChildren = toolBar.getChildren(); HashSet<MOpaqueToolItem> oldModelItems = new HashSet<MOpaqueToolItem>(); for (MToolBarElement itemModel : modelChildren) {
public static boolean processAddition(final MToolBar toolBarModel, MToolBarContribution toolBarContribution, List<MToolBarElement> contributions, HashSet<String> existingSeparatorNames) { int idx = getIndex(toolBarModel, toolBarContribution.getPositionInParent()); if (idx == -1) { return false; } for (MToolBarElement item : toolBarContribution.getChildren()) { if (item instanceof MToolBarSeparator && existingSeparatorNames.contains(item.getElementId())) { // skip this, it's already there continue; } MToolBarElement copy = (MToolBarElement) EcoreUtil.copy((EObject) item); if (DEBUG) { trace("addToolBarContribution " + copy, toolBarModel.getWidget(), toolBarModel); //$NON-NLS-1$ } toolBarModel.getChildren().add(idx++, copy); contributions.add(copy); if (copy instanceof MToolBarSeparator && copy.getElementId() != null) { existingSeparatorNames.add(copy.getElementId()); } } return true; }
List<MToolBarElement> modelChildren = toolBar.getChildren(); HashSet<MToolItem> oldModelItems = new HashSet<>(); for (MToolBarElement itemModel : modelChildren) {
shared = (MToolBarSeparator) copy; renderer.linkElementToContributionRecord(copy, this); toolbarModel.getChildren().add(idx++, copy); } else { copy = shared; generatedElements.add(copy); renderer.linkElementToContributionRecord(copy, this); toolbarModel.getChildren().add(idx++, copy);
shared = (MToolBarSeparator) copy; renderer.linkElementToContributionRecord(copy, this); toolbarModel.getChildren().add(idx++, copy); } else { copy = shared; generatedElements.add(copy); renderer.linkElementToContributionRecord(copy, this); toolbarModel.getChildren().add(idx++, copy);
@Override public void doProcessContent(MToolBar element) { WToolBar<N> toolbar = getWidget(element); if( toolbar == null ) { getLogger().error("Could not find widget for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$ return; } for (MToolBarElement item : element.getChildren()) { if (item.isToBeRendered()) { WWidget<MToolBarElement> itemWidget = engineCreateWidget(item); if (itemWidget != null && isChildRenderedAndVisible(item)) { toolbar.addChild(itemWidget); } } } }
MPart mPart = (MPart) element; MToolBar toolbar = mPart.getToolbar(); if (toolbar != null && toolbar.getChildren() != null) { toolbar.updateLocalization(); updateLocalization(toolbar.getChildren());