@Override public MPartDescriptor getPartDescriptor(String id) { MApplication application = appContext.get(MApplication.class); // If the id contains a ':' use the part before it as the descriptor id int colonIndex = id == null ? -1 : id.indexOf(':'); String descId = colonIndex == -1 ? id : id.substring(0, colonIndex); for (MPartDescriptor descriptor : application.getDescriptors()) { if (descriptor.getElementId().equals(descId)) { return descriptor; } } return null; }
private static MPartDescriptor getViewDescriptor(MApplication app, String id) { List<MPartDescriptor> descriptors = app.getDescriptors(); for (MPartDescriptor descriptor : descriptors) { if (id.equals(descriptor.getElementId()) && isView(descriptor)) { return descriptor; } } return null; }
public void restoreDefaultModel() { application.getTags().clear(); application.getPersistedState().clear(); application.getSnippets().clear(); application.getDescriptors().clear(); application.getChildren().clear(); application.getChildren().addAll(defaultWindows); }
/** * Determines the views and categories for the top level */ private Set<Object> determineTopLevelElements(Object element) { List<MPartDescriptor> descriptors = ((MApplication) element).getDescriptors(); Set<String> categories = new HashSet<>(); Set<MPartDescriptor> visibleViews = new HashSet<>(); for (MPartDescriptor descriptor : descriptors) { // only process views and hide views which are filtered by // activities if (!isView(descriptor) || isFilteredByActivity(descriptor.getElementId())) { continue; } // determine the categories String category = descriptor.getCategory(); // if view has not category show it directly if (category == null) { visibleViews.add(descriptor); // otherwise just show the category } else { categories.add(category); } } Set<Object> combinedTopElements = new HashSet<>(); combinedTopElements.addAll(categories); combinedTopElements.addAll(visibleViews); return combinedTopElements; }
/** * @param categoryDescription * @return views with the category tag */ private Set<MPartDescriptor> determineViewsInCategory(String categoryDescription) { List<MPartDescriptor> descriptors = application.getDescriptors(); Set<MPartDescriptor> categoryDescriptors = new HashSet<>(); for (MPartDescriptor descriptor : descriptors) { if (isFilteredByActivity(descriptor.getElementId()) || isIntroView(descriptor.getElementId())) { continue; } String category = descriptor.getCategory(); if (categoryDescription.equals(category)) { categoryDescriptors.add(descriptor); } } return categoryDescriptors; }
/** * This addon listens to the {@link UILifeCycle#APP_STARTUP_COMPLETE} event. * * @param event * {@link Event} */ @Inject @Optional public void applicationStartUp(@EventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event) { List<MPartDescriptor> descriptors = application.getDescriptors(); Bundle bundle = FrameworkUtil.getBundle(getClass()); for (Iterator<MPartDescriptor> iterator = descriptors.iterator(); iterator.hasNext();) { MPartDescriptor partDescriptor = iterator.next(); boolean validPartDescriptor = isValidPartDescriptor(bundle, partDescriptor); if (!validPartDescriptor) { logger.warn("Removing part descriptor with the '" + partDescriptor.getElementId() //$NON-NLS-1$ + "' id and the '" + partDescriptor.getLocalizedLabel() //$NON-NLS-1$ + "' description. Points to the invalid '" + partDescriptor.getContributionURI() + "' class."); //$NON-NLS-1$ //$NON-NLS-2$ iterator.remove(); } } }
List<MPartDescriptor> descriptors = application.getDescriptors(); for (int i = 0; i < descriptors.size(); i++) { MPartDescriptor descriptor = descriptors.get(i);
private void createDescriptor(IConfigurationElement element, boolean e4View) { String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID); MPartDescriptor descriptor = null; List<MPartDescriptor> currentDescriptors = application.getDescriptors(); for (MPartDescriptor desc : currentDescriptors) { descriptor = modelService.createModelElement(MPartDescriptor.class); descriptor.setElementId(id); application.getDescriptors().add(descriptor);
/** * Use the dialog store to restore widget values to the values that they * held last time this dialog was used to completion. */ protected void restoreWidgetValues() { IDialogSettings settings = getDialogSettings(); String[] expandedCategoryIds = settings.getArray(STORE_EXPANDED_CATEGORIES_ID); if (expandedCategoryIds == null) return; if (expandedCategoryIds.length > 0) filteredTree.getViewer().setExpandedElements(expandedCategoryIds); String selectedPartId = settings.get(STORE_SELECTED_VIEW_ID); if (selectedPartId != null) { List<MPartDescriptor> descriptors = application.getDescriptors(); for (MPartDescriptor descriptor : descriptors) { if (selectedPartId.equals(descriptor.getElementId())) { filteredTree.getViewer() .setSelection(new StructuredSelection(descriptor), true); break; } } } }
List<MPartDescriptor> currentDescriptors = application.getDescriptors(); for (MPartDescriptor desc : currentDescriptors) { descriptor.setContributionURI(CompatibilityPart.COMPATIBILITY_EDITOR_URI); descriptor.setCategory("org.eclipse.e4.primaryDataStack"); //$NON-NLS-1$ application.getDescriptors().add(descriptor);
for (MPartDescriptor desc : application.getDescriptors()) { for (MPart part : modelService.findElements(application, desc.getElementId(), MPart.class, null)) { if (part.getLabel() == null) {