private static String getContextName(MApplicationElement element) { StringBuilder builder = new StringBuilder(element.getClass().getSimpleName()); String elementId = element.getElementId(); if (elementId != null && elementId.length() != 0) { builder.append(" (").append(elementId).append(") "); //$NON-NLS-1$ //$NON-NLS-2$ } builder.append("Context"); //$NON-NLS-1$ return builder.toString(); }
@Override public boolean select(MApplicationElement element) { if (id != null && !id.equals(element.getElementId())) { return false; } if (clazz != null && !(clazz.isInstance(element))) { return false; } if (tagsToMatch != null) { List<String> elementTags = element.getTags(); for (String tag : tagsToMatch) { if (!elementTags.contains(tag)) { return false; } } } return true; } }
@Override public Color getForeground(Object element) { if (element instanceof MApplicationElement) { String elementId = ((MApplicationElement) element).getElementId(); MPerspective activePerspective = modelService.getActivePerspective(window); if(partService.isPartOrPlaceholderInPerspective(elementId, activePerspective)){ return dimmedForeground; } } return null; } }
private void createIdentifierTracker(MApplicationElement item) { if (item.getElementId() != null && item.getElementId().length() > 0) { String id = namespaceIdentifier + "/" + item.getElementId(); //$NON-NLS-1$ item.getPersistedState().put(MenuManagerRenderer.VISIBILITY_IDENTIFIER, id); final IIdentifier identifier = activityManager.getIdentifier(id); if (identifier != null) { application.getContext().set(identifier.getId(), identifier.isEnabled()); identifier.addIdentifierListener(idUpdater); } } }
public static MApplicationElement findElementById(MApplicationElement element, String id) { if (id == null || id.length() == 0) { return null; } // is it me? if (id.equals(element.getElementId())) { return element; } // Recurse if this is a container EList<EObject> elements = ((EObject) element).eContents(); for (EObject childElement : elements) { if (!(childElement instanceof MApplicationElement)) { continue; } MApplicationElement result = findElementById((MApplicationElement) childElement, id); if (result != null) { return result; } } return null; }
public static MApplicationElement findElementById(MApplicationElement element, String id) { if (id == null || id.length() == 0) { return null; } // is it me? if (id.equals(element.getElementId())) { return element; } // Recurse if this is a container EList<EObject> elements = ((EObject) element).eContents(); for (EObject childElement : elements) { if (!(childElement instanceof MApplicationElement)) { continue; } MApplicationElement result = findElementById((MApplicationElement) childElement, id); if (result != null) { return result; } } return null; }
elements.toArray(tmp); for(MApplicationElement element : tmp) { String elementID = element.getElementId(); boolean found = false; if ((elementID != null) && (elementID.length() != 0)) { if (!elementID.equals(existingEObject.getElementId())) { continue;
elements.toArray(tmp); for(MApplicationElement element : tmp) { String elementID = element.getElementId(); boolean found = false; if ((elementID != null) && (elementID.length() != 0)) { if (!elementID.equals(existingEObject.getElementId())) { continue;
@Inject @Optional private void subscribeTopicUpdateToolbarEnablement( @UIEventTopic(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC) Event eventData) { final Object v = eventData != null ? eventData.getProperty(IEventBroker.DATA) : UIEvents.ALL_ELEMENT_ID; Selector s; if (v instanceof Selector) { s = (Selector) v; } else { if (v == null || UIEvents.ALL_ELEMENT_ID.equals(v)) { s = ALL_SELECTOR; } else { s = element -> v.equals(element.getElementId()); } } getUpdater().updateContributionItems(s); }
@Override public MUIElement cloneSnippet(MSnippetContainer snippetContainer, String snippetId, MWindow refWin) { if (snippetContainer == null || snippetId == null || snippetId.length() == 0) { return null; } MApplicationElement elementToClone = null; for (MApplicationElement snippet : snippetContainer.getSnippets()) { if (snippetId.equals(snippet.getElementId())) { elementToClone = snippet; break; } } if (elementToClone == null) { return null; } EObject eObj = (EObject) elementToClone; MUIElement element = (MUIElement) EcoreUtil.copy(eObj); MUIElement appElement = refWin == null ? null : refWin.getParent(); if (appElement instanceof MApplication) { getNullRefPlaceHolders(element, refWin, true); } return element; }
if( elementId.equals((list.get(i)).getElementId()) ) { tmpIndex = i; break;
/** * Remove all traces of any launch bars found in the model. Required on startup as the * {@linkplain IntroLaunchBar} instances may not be have been rendered yet and so are * disconnected from the {@link IntroPlugin}'s state. * * @param workbench * the workbench to process */ public static void destroyAll(IWorkbench workbench) { EModelService modelService = workbench.getService(EModelService.class); MApplication application = workbench.getService(MApplication.class); List<MToolControl> candidates = modelService.findElements(application, MToolControl.class, EModelService.IN_TRIM, toolControl -> LAUNCHBAR_ID.equals(toolControl.getElementId()) && BUNDLECLASS_URI.equals(((MToolControl) toolControl).getContributionURI())); for (MToolControl trimControl : candidates) { if (trimControl.getParent() != null) { trimControl.getParent().getChildren().remove(trimControl); } } }
if( elementId.equals((list.get(i)).getElementId()) ) { tmpIndex = i; break;
MApplicationElement realElement = ModelUtils.findElementById(application, importedElement.getElementId()); if (realElement == null) { logger.warn("Could not resolve an import element for '" + realElement + "'"); //$NON-NLS-1$ //$NON-NLS-2$
@PostConstruct void init(IEventBroker eventBroker) { EventProcessor.attachChildProcessor(eventBroker, this); EventProcessor.attachVisibleProcessor(eventBroker, this); Selector noop = m -> true; eventBroker.subscribe(ScopedObjectFactory.KEYMODIFED_TOPIC, e -> checkExecute(noop)); eventBroker.subscribe(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, e -> { Object d = e.getProperty(IEventBroker.DATA); if (d instanceof Selector) { checkExecute((Selector) d); } else if (UIEvents.ALL_ELEMENT_ID.equals(d)) { checkExecute(noop); } else if (d != null) { checkExecute(m -> d.equals(m.getElementId())); } }); eventBroker.subscribe(UIEvents.Dirtyable.TOPIC_DIRTY, e -> checkExecute(noop)); this.context.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { context.get(IServiceConstants.ACTIVE_CONTEXTS); context.get(IServiceConstants.ACTIVE_SELECTION); context.get(IServiceConstants.ACTIVE_PART); checkExecute(noop); return true; } }); do_init(eventBroker); }