/** Constructor */ public ContentMRUAction( int order, INavigatorContentDescriptor contentDescriptor, INavigatorContentService contentService, CommonViewer commonViewer) { super( "" + order + " " + contentDescriptor.getName(), AS_CHECK_BOX); // $NON-NLS-1$//$NON-NLS-2$ this.contentDescriptor = contentDescriptor; this.contentService = contentService; this.commonViewer = commonViewer; setChecked(contentService.isActive(contentDescriptor.getId())); }
/* (non-Javadoc) * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object) */ @Override public String getDescription(Object element) { if (element instanceof INavigatorContentDescriptor) { INavigatorContentDescriptor ncd = (INavigatorContentDescriptor) element; String desc = NLS.bind( Messages.CommonFilterDescriptorLabelProvider_ContentExtensionDescription, new Object[] {ncd.getName()}); return desc; } return null; }
/* * (non-Javadoc) * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { Set<String> activeIds = new HashSet<String>(); String[] visibleIds = contentService.getVisibleExtensionIds(); if (visibleIds != null) { for (String visibleId : visibleIds) { if (contentService.isActive(visibleId)) activeIds.add(visibleId); } } if (isChecked()) activeIds.add(contentDescriptor.getId()); else activeIds.remove(contentDescriptor.getId()); String[] idsToActivate = activeIds.toArray(new String[activeIds.size()]); UpdateActiveExtensionsOperation updateExtensions = new UpdateActiveExtensionsOperation(commonViewer, idsToActivate); updateExtensions.execute(null, null); }