public static void disposeEditorActionBars(EditorActionBars actionBars) { actionBars.removeRef(); if (actionBars.getRef() <= 0) { String type = actionBars.getEditorType(); Set<EditorActionBars> set = actionCache.get(type); if (set != null) { set.remove(actionBars); } // refresh the cool bar manager before disposing of a cool item ICoolBarManager2 coolBar = (ICoolBarManager2) ((WorkbenchWindow) actionBars.getPage().getWorkbenchWindow()).getCoolBarManager2(); if (coolBar != null) { coolBar.refresh(); } actionBars.dispose(); } }
/* * Creates the action bars for an editor. Editors of the same type should * share a single editor action bar, so this implementation may return an * existing action bar vector. */ private static EditorActionBars createEditorActionBars( WorkbenchPage page, EditorDescriptor desc, final IEditorSite site) { // Get the editor type. String type = desc.getId(); // If an action bar already exists for this editor type return it. Set<EditorActionBars> candidates = actionCache.get(type); if (candidates != null) { for (EditorActionBars candidate : candidates) { if (candidate.getPage() == page) { candidate.addRef(); return candidate; } } } // Create a new action bar set. EditorActionBars actionBars = new EditorActionBars(page, page.getWorkbenchWindow(), type); actionBars.addRef(); if (candidates == null) { candidates = new HashSet<EditorActionBars>(3); candidates.add(actionBars); actionCache.put(type, candidates); } else candidates.add(actionBars); // Read base contributor. IEditorActionBarContributor contr = desc.createActionBarContributor(); if (contr != null) { actionBars.setEditorContributor(contr); contr.init(actionBars, page); } // Read action extensions. EditorActionBuilder builder = new EditorActionBuilder(); contr = builder.readActionExtensions(desc); if (contr != null) { actionBars.setExtensionContributor(contr); contr.init(actionBars, page); } // Return action bars. return actionBars; }