public void mergeIntoModel( ArrayList<MMenuContribution> menuContributions, ArrayList<MToolBarContribution> toolBarContributions, ArrayList<MTrimContribution> trimContributions) { if (location.getPath() == null || location.getPath().length() == 0) { WorkbenchPlugin.log( "MenuFactoryGenerator.mergeIntoModel: Invalid menu URI: " + location); // $NON-NLS-1$ return; } if (inToolbar()) { if (MenuAdditionCacheEntry.isInWorkbenchTrim(location)) { // processTrimChildren(trimContributions, toolBarContributions, // configElement); } else { String query = location.getQuery(); if (query == null || query.length() == 0) { query = "after=additions"; // $NON-NLS-1$ } processToolbarChildren(toolBarContributions, configElement, location.getPath(), query); } return; } MMenuContribution menuContribution = MenuFactoryImpl.eINSTANCE.createMenuContribution(); String idContrib = MenuHelper.getId(configElement); if (idContrib != null && idContrib.length() > 0) { menuContribution.setElementId(idContrib); } if ("org.eclipse.ui.popup.any".equals(location.getPath())) { // $NON-NLS-1$ menuContribution.setParentId("popup"); // $NON-NLS-1$ } else { menuContribution.setParentId(location.getPath()); } String query = location.getQuery(); if (query == null || query.length() == 0) { query = "after=additions"; // $NON-NLS-1$ } menuContribution.setPositionInParent(query); menuContribution.getTags().add("scheme:" + location.getScheme()); // $NON-NLS-1$ String filter = ContributionsAnalyzer.MC_MENU; if ("popup".equals(location.getScheme())) { // $NON-NLS-1$ filter = ContributionsAnalyzer.MC_POPUP; } menuContribution.getTags().add(filter); menuContribution.setVisibleWhen(MenuHelper.getVisibleWhen(configElement)); ContextFunction generator = new ContributionFactoryGenerator(configElement, 0); menuContribution.getTransientData().put(ContributionRecord.FACTORY, generator); menuContributions.add(menuContribution); }
private void processToolbarChildren( ArrayList<MToolBarContribution> contributions, IConfigurationElement toolbar, String parentId, String position) { MToolBarContribution toolBarContribution = MenuFactoryImpl.eINSTANCE.createToolBarContribution(); String idContrib = MenuHelper.getId(toolbar); if (idContrib != null && idContrib.length() > 0) { toolBarContribution.setElementId(idContrib); } toolBarContribution.setParentId(parentId); toolBarContribution.setPositionInParent(position); toolBarContribution.getTags().add("scheme:" + location.getScheme()); // $NON-NLS-1$ ContextFunction generator = new ContributionFactoryGenerator(configElement, 1); toolBarContribution.getTransientData().put(ToolBarContributionRecord.FACTORY, generator); contributions.add(toolBarContribution); }
private boolean inToolbar() { return location.getScheme().startsWith("toolbar"); // $NON-NLS-1$ }