/** * Initialize the contributor with the provided contributor id. * * @param contributorId the contributor id. */ private void initContributor(final String contributorId) { descriptorToTab = new HashMap(); if (contributor.getContributorId().equals(contributorId)) { /** default contributor from the workbench part. */ registry = TabbedPropertyRegistryFactory.getInstance().createRegistry(contributor); } else { /** selection contributor. */ selectionContributor = new TabbedPropertySheetPageContributorFromSelection(contributorId); registry = TabbedPropertyRegistryFactory.getInstance().createRegistry(selectionContributor); } currentContributorId = contributorId; tabListContentProvider = getTabListContentProvider(); hasTitleBar = hasTitleBar && registry.getLabelProvider() != null; if (tabbedPropertyViewer != null) { tabbedPropertyViewer.setContentProvider(tabListContentProvider); } /** Add a label provider change listener. */ if (hasTitleBar) { registry.getLabelProvider().addListener(this); } }
/** * Dispose the contributor with the provided contributor id. This happens on part close as well as * when contributors switch between the workbench part and contributor from a selection. * * @since 3.6 */ protected void disposeContributor() { /** If the current tab is about to be disposed we have to call aboutToBeHidden */ if (currentTab != null) { currentTab.aboutToBeHidden(); currentTab = null; } disposeTabs(descriptorToTab.values()); descriptorToTab = new HashMap(); /** Remove the label provider change listener. */ if (hasTitleBar && registry != null) { registry.getLabelProvider().removeListener(this); } if (selectionContributor != null) { /** remove the selection contributed registry. */ TabbedPropertyRegistryFactory.getInstance().disposeRegistry(selectionContributor); selectionContributor = null; } }
/** @see org.eclipse.ui.part.IPage#dispose() */ @Override public void dispose() { disposeContributor(); if (widgetFactory != null) { widgetFactory.dispose(); widgetFactory = null; } /** Remove the part activation listener. */ if (cachedWorkbenchWindow != null) { cachedWorkbenchWindow.getPartService().removePartListener(partActivationListener); cachedWorkbenchWindow = null; } if (registry != null) { TabbedPropertyRegistryFactory.getInstance().disposeRegistry(contributor); registry = null; } contributor = null; currentSelection = null; }