private void updateToolItem() { final ToolItem item = (ToolItem) this.widget; final boolean shouldBeEnabled = isEnabled(); // disabled command + visibility follows enablement == disposed if (item.isDisposed()) { return; } final String text = this.label; if ((this.icon == null || (this.mode & MODE_FORCE_TEXT) == MODE_FORCE_TEXT) && text != null) { item.setText(text); } final String toolTipText = getToolTipText(text); item.setToolTipText(toolTipText); if (item.getSelection() != this.checkedState) { item.setSelection(this.checkedState); } if (item.getEnabled() != shouldBeEnabled) { item.setEnabled(shouldBeEnabled); } }
/* * (non-Javadoc) * * @see org.eclipse.jface.action.ContributionItem#update(java.lang.String) */ public void update(String id) { if (widget != null) { if (widget instanceof MenuItem) { MenuItem item = (MenuItem) widget; String text = label; if (text == null) { if (command != null) { try { text = command.getCommand().getName(); } catch (NotDefinedException e) { WorkbenchPlugin.log( "Update item failed " //$NON-NLS-1$ + getId(), e); } } } // TODO: [bm] key bindings // text = updateMnemonic(text); // // String keyBindingText = null; // if (command != null) { // TriggerSequence[] bindings = bindingService // .getActiveBindingsFor(command); // if (bindings.length > 0) { // keyBindingText = bindings[0].format(); // } // } // if (text != null) { // if (keyBindingText == null) { item.setText(text); // } else { // item.setText(text + '\t' + keyBindingText); // } // } updateIcons(); if (item.getSelection() != checkedState) { item.setSelection(checkedState); } boolean shouldBeEnabled = isEnabled(); if (item.getEnabled() != shouldBeEnabled) { item.setEnabled(shouldBeEnabled); } } else if (widget instanceof ToolItem) { ToolItem item = (ToolItem) widget; if (icon != null) { updateIcons(); } else if (label != null) { item.setText(label); } if (tooltip != null) item.setToolTipText(tooltip); else { String text = label; if (text == null) { if (command != null) { try { text = command.getCommand().getName(); } catch (NotDefinedException e) { WorkbenchPlugin.log( "Update item failed " //$NON-NLS-1$ + getId(), e); } } } if (text != null) { item.setToolTipText(text); } } if (item.getSelection() != checkedState) { item.setSelection(checkedState); } boolean shouldBeEnabled = isEnabled(); if (item.getEnabled() != shouldBeEnabled) { item.setEnabled(shouldBeEnabled); } } } }